/* ═══════════════════════════════════════════
   Team Tasks — стили страниц Статистика / Профиль / Пользователи / Компании
   Только префикс pg-; базовые классы (.card .field .btn .table .statbar …) — в styles.css.
   Цвета только через токены; пороги КПД — --green / --red.
   ═══════════════════════════════════════════ */

/* ─────────── Общее ─────────── */
.pg-stats, .pg-profile, .pg-users, .pg-companies{display:flex; flex-direction:column; gap:16px; padding-bottom:32px}
.pg-stats [hidden], .pg-profile [hidden], .pg-users [hidden], .pg-companies [hidden], .pg-form [hidden]{display:none !important}
.pg-profile{max-width:560px}
.pg-companies{max-width:640px}
.pg-stats .card + .card, .pg-profile .card + .card, .pg-users .card + .card, .pg-companies .card + .card{margin-top:0}   /* расстояние задаёт gap контейнера */
.pg-card{display:flex; flex-direction:column; gap:12px}
.pg-card > .card-title{margin-bottom:2px}
.pg-actions{margin-top:4px; flex-wrap:wrap}
.pg-toolbar{gap:10px; flex-wrap:wrap}
.pg-loading{padding:24px 4px}

/* Вкладки настроек «Компании · Пользователи» */
.pg-tabs{align-self:flex-start}
.pg-tabs .seg{padding:5px 14px; font-size:12.5px}
.pg-banner{display:flex; align-items:center; gap:10px; flex-wrap:wrap}
.pg-hint{font-size:11.5px; color:var(--text-3); line-height:1.4}
.pg-hint b{color:var(--text-2); font-weight:600}
.pg-ok{color:var(--green); font-weight:700}
.pg-nowrap{white-space:nowrap}
.pg-center{text-align:center}
.pg-right{text-align:right}
.pg-inactive .pg-user, .pg-inactive td.mono, .pg-inactive td.muted, .pg-inactive td.pg-num{opacity:.55}   /* переключатель и кнопки остаются яркими */
.pg-busy{opacity:.6; pointer-events:none}

/* Поля форм */
.pg-field{position:relative}
.pg-field .pg-err{display:block; font-size:11.5px; color:var(--red); margin-top:2px}
.pg-field .row{gap:8px}
.pg-field .row input{flex:1; min-width:0}
.pg-grid2{display:grid; grid-template-columns:1fr 1fr; gap:12px}
.pg-grid4{display:grid; grid-template-columns:repeat(4, 1fr); gap:12px}
.pg-check{gap:8px; align-self:end; padding:6px 0; cursor:pointer; font-size:13px}
.pg-check input{width:16px; height:16px; accent-color:var(--accent); margin:0}
.pg-form{display:flex; flex-direction:column; gap:12px}
.pg-form p{margin:0; font-size:12.5px}
input.pg-time, .pg-quiet input{width:auto}
.pg-quiet{gap:8px; flex-wrap:wrap}

/* Таблицы в карточке */
.pg-table-card{padding:0; overflow:hidden}
.pg-scroll{overflow-x:auto}
.pg-table{width:100%; border-collapse:collapse}
.pg-table th, .pg-table td{padding:8px 12px; vertical-align:middle}
.pg-table th:first-child, .pg-table td:first-child{padding-left:16px}
.pg-table th:last-child, .pg-table td:last-child{padding-right:16px}
.pg-num{text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap}
.pg-user .row{gap:8px}
.pg-name{font-weight:500}
.pg-table-hint{font-size:11.5px; padding:8px 16px 10px; border-top:1px solid var(--line-soft)}
.pg-chip{font-size:10.5px; margin-left:6px; vertical-align:middle}

/* Пороги КПД */
.pg-kpd{font-weight:700}
.pg-kpd-good{color:var(--green)}
.pg-kpd-bad{color:var(--red)}
.pg-kpd-null{color:var(--text-3)}

/* ─────────── Статистика ─────────── */
.pg-segmented{flex-wrap:wrap}
.pg-custom{gap:8px; flex-wrap:wrap}
.pg-custom input[type="date"]{width:auto}
.pg-custom-err{color:var(--red)}
.pg-statbar{margin-top:0}
.pg-menu-wrap{position:relative}
.pg-menu{position:absolute; right:0; top:calc(100% + 6px); min-width:180px; background:var(--surface); border:1px solid var(--line);
  border-radius:var(--r-sm); box-shadow:var(--shadow-lg); padding:4px; z-index:20; display:flex; flex-direction:column}
.pg-menu-item{display:block; padding:7px 10px; border-radius:6px; font-size:13px; color:var(--text); text-decoration:none; white-space:nowrap}
.pg-menu-item:hover{background:var(--side-hover)}
.pg-table th[data-sort]{cursor:pointer; user-select:none; white-space:nowrap}
.pg-table th[data-sort]:hover{color:var(--text)}
.pg-table th.pg-sorted{color:var(--text)}
tr.pg-row{cursor:pointer}
tr.pg-row:focus-visible{outline:2px solid var(--accent); outline-offset:-2px}
tr.pg-row.is-selected td{background:var(--accent-tint)}

/* Карточка сотрудника */
.pg-person{gap:12px}
.pg-person-head{gap:12px}
.pg-person-name{font-size:16px; font-weight:700; letter-spacing:-.01em}
.pg-person-title{min-width:0}
.pg-person-title .muted{font-size:12px}
.pg-person-kpd{font-size:30px; font-weight:700; letter-spacing:-.03em; font-variant-numeric:tabular-nums; line-height:1}
.pg-person-sub{font-size:12.5px}
.pg-self{font-size:12.5px}
.pg-close{font-size:20px; line-height:1}

/* Тренд — 8 CSS-столбиков */
.pg-trend{border-top:1px solid var(--line-soft); padding-top:10px}
.pg-trend-title{font-size:11px; text-transform:uppercase; letter-spacing:.05em; margin-bottom:6px}
.pg-bars{display:grid; grid-template-columns:repeat(8, 1fr); gap:6px; height:110px; align-items:end}
.pg-bar-col{display:flex; flex-direction:column; align-items:center; height:100%; justify-content:flex-end; gap:3px; cursor:default}
.pg-bar-val{font-size:10.5px; color:var(--text-3); font-variant-numeric:tabular-nums; line-height:1}
.pg-bar-track{width:100%; height:88px; background:var(--surface-2); border-radius:6px; display:flex; align-items:flex-end; overflow:hidden}
.pg-bar{width:100%; background:var(--accent); border-radius:6px 6px 0 0; transform-origin:bottom; animation:pg-grow .18s ease}   /* столбик вырастает снизу через transform, не через height */
@keyframes pg-grow{from{transform:scaleY(0)}}
@media (prefers-reduced-motion:reduce){.pg-bar{animation:none}}
.pg-bar.pg-kpd-good{background:var(--green)}
.pg-bar.pg-kpd-bad{background:var(--red)}
.pg-bar.pg-bar-null{background:transparent}
.pg-bar-col:hover .pg-bar-track{outline:1px solid var(--line)}
.pg-trend-axis{display:flex; justify-content:space-between; font-size:10.5px; margin-top:4px}

/* Списки задач в <details> */
.pg-details{border-top:1px solid var(--line-soft); padding-top:8px}
.pg-details summary{cursor:pointer; font-size:13px; font-weight:600; padding:4px 0; list-style-position:inside; user-select:none}
.pg-details summary:hover{color:var(--accent)}
.pg-details .pg-none{font-size:12.5px; padding:4px 0 6px 16px}
.pg-formula p{font-size:12.5px; line-height:1.5; color:var(--text-2); margin:4px 0 4px 16px}
.pg-items{display:flex; flex-direction:column; padding:2px 0 4px}
.pg-item{display:flex; align-items:center; gap:10px; width:100%; text-align:left; border:0; background:transparent; color:var(--text);
  font:inherit; padding:7px 8px; border-radius:var(--r-sm); cursor:pointer; min-height:40px}
.pg-item:hover{background:var(--side-hover)}
.pg-item:focus-visible{outline:2px solid var(--accent); outline-offset:-2px}
.pg-item-body{flex:1; min-width:0; display:flex; flex-direction:column; gap:2px}
.pg-item-title{font-size:13px; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.pg-item-meta{font-size:11.5px}
.pg-item-pts{font-size:11.5px; font-variant-numeric:tabular-nums; white-space:nowrap}
.pg-dot{width:9px; height:9px; border-radius:50%; flex:none; background:var(--text-3)}
.pg-p-high{background:var(--p-high)}
.pg-p-medium{background:var(--p-medium)}
.pg-p-low{background:var(--p-low)}
.pg-p-none{background:var(--p-none)}

/* ─────────── Профиль ─────────── */
.pg-tg{display:flex; flex-direction:column; gap:12px}
.pg-tg-identity{gap:8px; font-size:13px; flex-wrap:wrap; padding-bottom:10px; border-bottom:1px solid var(--line-soft)}
.pg-bot-row{display:flex; flex-direction:column; gap:8px; font-size:13px}
.pg-bot-row + .pg-bot-row{border-top:1px solid var(--line-soft); padding-top:12px}
.pg-bot-name{font-size:13px; color:var(--text-2); overflow-wrap:anywhere}
.pg-bot-name b{color:var(--text); font-weight:600}
.pg-bot-body{display:flex; flex-direction:column; gap:8px}
.pg-bot-body .pg-actions{margin-top:0}
.pg-code{font-size:22px; letter-spacing:.18em; font-weight:700; padding:12px 16px; background:var(--surface-2); border:1px dashed var(--line);
  border-radius:var(--r-sm); text-align:center; user-select:all}
.pg-waiting{animation:pg-pulse 1.6s ease-in-out infinite}
@keyframes pg-pulse{0%,100%{opacity:.55} 50%{opacity:1}}
.pg-switch-row{gap:10px; padding:6px 0; border-bottom:1px solid var(--line-soft)}
.pg-switch-row:last-of-type{border-bottom:0}
.pg-switch-label{font-size:13px}
.btn.pg-ghost{border-color:transparent; background:transparent; color:var(--text-2)}
.btn.pg-ghost:hover{background:var(--surface-2); color:var(--text)}

/* ─────────── Пользователи ─────────── */
.pg-users-table select.pg-role{font:inherit; font-size:12.5px; padding:3px 6px; border:1px solid var(--line); border-radius:6px; background:var(--surface); color:var(--text)}
.pg-users-table select.pg-role:disabled{opacity:.6}
.pg-cred{justify-content:flex-start}
.pg-cred > div{flex:1; min-width:200px}
.pg-cred .mono{font-size:13px}
.pg-cred-tg{margin-top:4px}
.pg-users-table input.pg-phone{width:150px; font:inherit; font-size:12.5px; font-variant-numeric:tabular-nums; padding:3px 8px; min-height:27px;
  border:1px solid transparent; border-radius:6px; background:transparent; color:var(--text); outline:0; transition:border-color var(--t), box-shadow var(--t), background var(--t)}
.pg-users-table input.pg-phone:hover{border-color:var(--line)}
.pg-users-table input.pg-phone:placeholder-shown:not(:focus){border-color:var(--line-soft)}
.pg-users-table input.pg-phone:focus{border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-tint); background:var(--surface)}
.pg-users-table input.pg-phone.pg-saving{opacity:.6}
.pg-phone-cell{white-space:nowrap}
.pg-users-table select.pg-company-sel{font:inherit; font-size:12.5px; padding:3px 6px; border:1px solid var(--line); border-radius:6px; background:var(--surface); color:var(--text); max-width:180px}
.pg-users-table select.pg-company-sel:disabled{opacity:.6}
.pg-filter{gap:6px; flex-wrap:wrap}
.chip.pg-filter-chip{font:inherit; font-size:12px; font-weight:500; line-height:1.4; padding:4px 11px; border-radius:999px; cursor:pointer;
  border:1px solid var(--line); background:transparent; color:var(--text-2); max-width:100%; overflow:hidden; text-overflow:ellipsis;
  transition:background var(--t), color var(--t), border-color var(--t)}
.chip.pg-filter-chip:hover{background:var(--side-hover); color:var(--text)}
.chip.pg-filter-chip:focus-visible{outline:2px solid var(--accent); outline-offset:1px}
.chip.pg-filter-chip.is-active{background:var(--accent-tint); border-color:transparent; color:var(--accent)}
.pg-field-company select{width:100%}

/* ─────────── Компании ─────────── */
.pg-company{gap:0}
.pg-company-head{gap:10px; padding-bottom:12px; flex-wrap:wrap}
.pg-company-head .card-title{margin-bottom:0; font-size:15px; min-width:0; overflow-wrap:anywhere}
.pg-company-head .muted{font-size:12px; white-space:nowrap}
.pg-block{display:flex; flex-direction:column; gap:12px; padding:14px 0}
.pg-block + .pg-block{border-top:1px solid var(--line-soft)}
.pg-block:last-child{padding-bottom:0}
.pg-block-title{font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:.05em; color:var(--text-3)}
.pg-botstate{font-size:13px}
.pg-botstate .row{gap:8px}
.pg-botstate .pg-dot{background:var(--text-3)}
.pg-dot.pg-dot-ok{background:var(--green)}
.pg-dot.pg-dot-bad{background:var(--red)}
.pg-dot.pg-dot-wait{background:var(--p-medium); animation:pg-pulse 1.2s ease-in-out infinite}
.pg-formula-preview{background:var(--surface-2); border-radius:var(--r-sm); padding:10px 12px}
.pg-formula-text{margin:4px 0 0; font-size:12.5px; line-height:1.5; color:var(--text-2)}

/* ─────────── Секретарь (§11.7) ─────────── */
.pg-secretary{display:flex; flex-direction:column; gap:16px; padding-bottom:32px; max-width:760px}
.pg-secretary [hidden]{display:none !important}
.pg-secretary .card + .card{margin-top:0}
.pg-ask{display:flex; flex-direction:column; gap:10px}
.pg-ask textarea{width:100%; min-height:58px; resize:vertical}
.pg-ask-foot{display:flex; align-items:center; gap:10px; flex-wrap:wrap}
.pg-ask-foot .hint{flex:1; min-width:200px}
.pg-progress{display:flex; align-items:center; gap:10px; flex-wrap:wrap; font-size:12.5px}
.pg-progress b{font-weight:600}
.pg-entries{display:flex; flex-direction:column; gap:10px}
.pg-entry{display:flex; flex-direction:column; gap:8px; padding:12px 14px}
.pg-entry-head{display:flex; align-items:center; gap:8px; flex-wrap:wrap; font-size:12px; color:var(--text-2)}
.pg-entry-head .pg-src{font-size:14px}
.pg-entry-head .pg-name{color:var(--text); font-weight:600}
.pg-entry-head .pg-when{color:var(--text-3)}
.pg-entry-text{font-size:13.5px; line-height:1.45}
.pg-entry audio{width:100%; max-width:420px; height:36px}
.pg-entry-result{display:flex; flex-direction:column; gap:6px; padding:9px 11px; border-radius:var(--r-sm); background:var(--surface-2); font-size:12.5px; line-height:1.45}
.pg-entry-result.pg-bad{background:var(--red-bg); color:var(--red)}
.pg-entry-result .pg-lbl{font-weight:600; color:var(--text-2); margin-right:4px}
.pg-entry-result .pg-tasklinks{display:flex; flex-direction:column; gap:2px}
.pg-entry-result .pg-tasklink{display:inline-flex; gap:6px; align-items:baseline; border:0; background:transparent; color:var(--accent); font:inherit; font-size:12.5px; padding:0; cursor:pointer; text-align:left}
.pg-entry-result .pg-tasklink:hover{text-decoration:underline}
.pg-entry-result .pg-tasklink .muted{color:var(--text-3)}
.pg-outcome{font-size:11px; padding:0 8px; line-height:18px; border-radius:999px; background:var(--surface); border:1px solid var(--line-soft); white-space:nowrap}
.pg-outcome.ok{color:var(--green); border-color:transparent; background:var(--green-bg)}
.pg-outcome.warn{color:var(--amber); border-color:transparent; background:var(--amber-bg)}
.pg-outcome.bad{color:var(--red); border-color:transparent; background:var(--red-bg)}
.pg-entry-actions{display:flex; gap:8px; flex-wrap:wrap}
.pg-entry-check{display:flex; align-items:center; gap:8px; flex-wrap:wrap; font-size:12px; color:var(--text-3); border-top:1px solid var(--line-soft); padding-top:8px}
.pg-entry-check .btn.sm{height:26px; padding:0 10px; font-size:11.5px}
.pg-entry-check .btn.sm.is-on{background:var(--accent-tint); border-color:transparent; color:var(--accent)}
.pg-entry-check .btn.sm.is-on.bad{background:var(--red-bg); color:var(--red)}
.pg-entry-note{font-style:italic}

/* Панель задачи: голосовое поручение (§11.7) */
.d-voice audio{width:100%; height:36px; margin-top:2px}
.d-voice-text{font-size:12.5px; line-height:1.45; color:var(--text-2); font-style:italic; margin-top:8px}

/* ─────────── Адаптив ─────────── */
@media (max-width:760px){
  .pg-grid2, .pg-grid4{grid-template-columns:1fr 1fr}
  .pg-bars{height:90px}
  .pg-bar-track{height:70px}
  .pg-person-kpd{font-size:24px}
  .pg-item{min-height:44px}
  .pg-toolbar .spacer{flex-basis:100%}
  .pg-tabs{align-self:stretch}
  .pg-tabs .seg{flex:1; justify-content:center; min-height:36px}
  .chip.pg-filter-chip{padding:8px 12px}
  .pg-users-table select.pg-company-sel{min-height:36px}
}
@media (max-width:480px){
  .pg-grid2, .pg-grid4{grid-template-columns:1fr}
  .pg-bar-val{display:none}
}
