/* 16.10.2026 «Визуальная доводка»: единые отступы шапок панелей, таблицы (числа вправо, подсказка о прокрутке, карточки на телефоне),
   сетка списка людей, выплаты, графики с малым числом замеров. Подключается последним и только уточняет то, что задано выше. */

/* ---- шапки панелей: описание не прилипает к таблице под ним ---- */
.panel-head { padding-bottom: 18px; }
.panel-head + .chart-wrap { padding-top: 0; min-height: 0; }
.panel-head + .panel-body { padding-top: 0; }
.panel-head + .table-wrap { border-top: 1px solid var(--line); }
.panel-head > div:first-child { min-width: 0; }
.panel-head h2 + p { max-width: 78ch; }
.panel + .panel, .panel + .stats, .stats + .panel { margin-top: 22px; }
.panel-body:empty { display: none; }
.subheading { margin: 34px 0 16px; }

/* ---- таблицы ---- */
.table { min-width: 0; }
.table th { white-space: normal; vertical-align: bottom; line-height: 1.3; padding: 14px 12px; }
.table td { padding: 16px 12px; }
.table th:first-child, .table td:first-child { padding-left: 22px; }
.table th:last-child, .table td:last-child { padding-right: 22px; }
.table th.num, .table td.number-cell { text-align: right; }
.number-cell, .stat .number, .platform-number, .pub-nums dd { font-variant-numeric: tabular-nums; }
.table .number-cell small, .table td.number-cell .pill { text-align: right; }
.table .btn.ghost { padding: 4px 8px; }
/* широкая таблица прокручивается: у края видна тень «там есть ещё» */
.table-wrap {
  background:
    linear-gradient(to right, var(--surface) 30%, transparent),
    linear-gradient(to left, var(--surface) 30%, transparent) 100% 0,
    radial-gradient(farthest-side at 0 50%, rgba(25, 30, 45, .13), rgba(25, 30, 45, 0)),
    radial-gradient(farthest-side at 100% 50%, rgba(25, 30, 45, .13), rgba(25, 30, 45, 0)) 100% 0;
  background-repeat: no-repeat;
  background-color: var(--surface);
  background-size: 44px 100%, 44px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}
.table .post-title { max-width: 260px; }
.table small { max-width: 240px; }

/* ---- кнопки ---- */
.btn abbr.term, .btn abbr { text-decoration: none; border: 0; cursor: inherit; }
.btn.ghost { padding: 4px 10px; }
.rate-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; }
.rate-line .btn, .rate-line .btn.ghost { margin: 0; padding-left: 0; padding-right: 0; }
.notice .btn { margin: 6px 0 0 8px; vertical-align: middle; }
.notice > .btn:first-child { margin-left: 0; }
.notice .actions .btn { margin: 0; }

/* ---- числа на плитках ---- */
.stat .number.long { white-space: nowrap; overflow-wrap: normal; font-size: clamp(24px, 2.1vw, 34px); }
.stat .number.text { font-size: 26px; font-weight: 600; letter-spacing: -.025em; padding: 4px 0; }

/* ---- график: подписи не слипаются; один замер — спокойная заметка вместо пустой рамки ---- */
.chart-labels { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 0 18px; }
.chart-labels span:nth-child(2) { text-align: center; }
.chart-labels span:last-child { text-align: right; }
.chart-wrap:has(.chart-few) { min-height: 0; padding: 4px 22px 22px; }
.empty.chart-few { padding: 22px 24px; border-radius: 16px; background: var(--surface-2); font-size: 13px; line-height: 1.6; }
.empty.chart-few strong { font-size: 15px; margin-bottom: 4px; }

/* ---- карточки заданий, проектов, участников ---- */
.brief-card > .actions { margin: 0 0 18px; }
.data-card h2 + .actions { margin: 12px 0 6px; }
.chat-row { padding: 6px 0; align-items: center; }
.chat-row > span:first-child { flex: 1 1 auto; font-weight: 500; }
.chat-row small { display: block; margin: 1px 0 0; font-size: 12px; font-weight: 400; white-space: nowrap; }
.chat-row .actions { flex: none; gap: 0; }
.chat-row .btn.ghost { padding: 4px 8px; font-size: 13px; }
.chat-list-head { min-height: 36px; }
.card-tools { gap: 8px; }
.member-card .actions { gap: 6px 4px; align-items: center; }
.member-card .btn.ghost { padding: 4px 10px; font-size: 13px; }
.member-card .accounts { margin: 12px 0; }
.status-row small { display: block; margin-top: 2px; font-size: 12px; color: var(--text-3); }
.status-row .actions { align-items: center; gap: 14px; flex-wrap: nowrap; }
.status-row > span:first-child { min-width: 0; }

/* ---- строки списка людей: колонки одной ширины у всех строк, справа — кнопки ---- */
.user-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 14px 0; }
.user-row > .cell-person { flex: 0 0 clamp(210px, 28%, 290px); min-width: 0; }
.user-row > .cell-person > div { min-width: 0; overflow-wrap: anywhere; }
.user-row > .user-meta { flex: 1 1 200px; min-width: 0; }
.user-row > .user-meta ~ * { flex: none; }
.user-row > .user-meta + * { margin-left: auto; }
.user-row > span:not([class]) { min-width: 82px; text-align: right; }
.user-row .btn { white-space: nowrap; }
.signups .user-row > .actions { gap: 8px; }

/* ---- выплаты ---- */
.payout-toolbar { margin: 22px 0 18px; gap: 12px 16px; }
.payout-toolbar label { font-size: 12px; font-weight: 500; color: var(--text-3); gap: 6px; }
.payout-toolbar select, .payout-toolbar input {
  min-height: 42px; min-width: 180px; padding: 9px 14px; border-radius: 12px; border: 1px solid var(--border-field);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 14px;
}
.payout-toolbar input:focus, .payout-toolbar select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 122, 255, .13); }
.payout-toolbar .actions { align-items: center; }
.panel > .payout-toolbar { margin: 0; padding: 22px 24px 14px; border-bottom: 1px solid var(--line); }
.panel > .payout-toolbar + .panel-body, .panel > .payout-toolbar + .notice { margin-top: 0; }
.table.payouts td:last-child { min-width: 0; }
.table.payouts .payout-item { padding: 4px 0; }
.table.payouts .btn.ghost { padding-left: 0; }
.payout-toolbar + .stats { margin-top: 0; }

/* ---- сегментные переключатели ---- */
.segmented + .segmented { margin-top: -6px; }

/* ---- страницы договоров: тот же шрифт и цвета, что у кабинета ---- */

@media (max-width: 960px) {
  .table th, .table td { padding-left: 10px; padding-right: 10px; }
}

@media (max-width: 680px) {
  .panel + .panel, .panel + .stats, .stats + .panel { margin-top: 16px; }
  .panel-head { padding-bottom: 14px; }
  .stat .number.long { font-size: 22px; }
  .stat .number.text { font-size: 20px; }
  .stat .number { white-space: normal; }
  .chart-labels { padding: 0 6px; gap: 6px; }
  .chart-wrap { padding-left: 14px; padding-right: 14px; }
  .segmented button:last-child:nth-child(odd) { grid-column: 1 / -1; }

  /* список людей: имя и статус — в первой строке, почта и роль — во второй, кнопки — в третьей */
  .user-row { gap: 8px 10px; padding: 14px 0; }
  .user-row > .cell-person { order: 1; flex: 1 1 0; }
  .user-row > span:not([class]) { order: 2; min-width: 0; }
  .user-row > .user-meta { order: 3; flex: 1 1 100%; padding-left: 43px; margin: -4px 0 0; }
  .user-row > .btn, .user-row > .actions { order: 4; }
  .user-row > .more-btn { order: 5; margin-left: auto; }
  .user-row > .user-meta + * { margin-left: 0; }
  .user-row > .btn { flex: 0 1 auto; }
  .user-row > .more-btn:only-of-type { margin-left: auto; }
  .signups .user-row > .actions { flex: 1 1 100%; padding-left: 43px; }
  .user-row .user-meta small, .user-row .user-meta { overflow-wrap: anywhere; }

  /* выплаты */
  .payout-toolbar { flex-direction: column; align-items: stretch; margin: 18px 0 14px; }
  .payout-toolbar select, .payout-toolbar input { width: 100%; min-width: 0; min-height: 44px; font-size: 16px; }
  .payout-toolbar .actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
  .payout-toolbar .actions .btn { width: 100%; white-space: normal; }
  .panel > .payout-toolbar { padding: 18px 16px 12px; margin: 0; }
  .status-row { flex-wrap: wrap; gap: 8px 18px; }
  .status-row .actions { flex-wrap: wrap; }

  /* таблицы без своих карточек: строка = карточка, у каждой ячейки подпись столбца */
  .table-wrap:has(> table.stack) { overflow-x: visible; background: none; }
  .table.stack { display: block; min-width: 0; width: 100%; }
  .table.stack thead { display: none; }
  .table.stack tbody { display: block; }
  .table.stack tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
  .table.stack tbody tr:last-child { border-bottom: 0; }
  .table.stack tbody tr:hover { background: none; }
  .table.stack td { display: block; min-width: 0; padding: 0; border: 0; text-align: left; overflow-wrap: anywhere; }
  .table.stack td:first-child { grid-column: 1 / -1; font-weight: 600; font-size: 14px; }
  .table.stack td:not([data-label]) { grid-column: 1 / -1; }
  .table.stack td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; font-size: 12px; font-weight: 400; color: var(--text-3); }
  .table.stack td:first-child::before { display: none; }
  .table.stack td.number-cell, .table.stack td.number-cell small { text-align: left; }
  .table.stack td small, .an-table.stack td.number-cell small { max-width: none; white-space: normal; margin-left: 0; }
  .table.stack tr.an-total { background: var(--surface-2); }
  .table.stack tr.an-total td { background: none; }
  .an-table.stack td.number-cell:has(small) { grid-column: 1 / -1; }
  .table.stack td .btn { max-width: 100%; white-space: normal; }

  /* таблицы-карточки выплат: подпись и значение ближе, отступы между карточками ровные */
  table.money-cards tr { margin: 0 0 12px !important; padding: 14px 16px !important; }
  table.money-cards td { padding: 5px 0 !important; text-align: left !important; }
  table.money-cards td.number-cell { text-align: left !important; }
}

/* аналитические таблицы: цена и пояснения под числом переносятся, а не растягивают таблицу */
.an-table td.number-cell small { white-space: normal; max-width: 150px; margin-left: auto; }
.an-table th { padding-top: 14px; padding-bottom: 14px; }

/* закрытие месяца: номер, отметка и название шага в одну строку, пояснение под названием */
.month-close .close-steps { list-style: none; counter-reset: step; margin: 0; padding: 0 26px 24px; display: grid; gap: 12px; }
.month-close .close-steps li { display: grid; grid-template-columns: 22px auto minmax(0, 1fr); gap: 2px 10px; align-items: baseline; margin: 0; counter-increment: step; }
.month-close .close-steps li::before { content: counter(step) "."; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.month-close .close-steps li strong { font-size: 15px; }
.month-close .close-steps li small { grid-column: 3; display: block; font-size: 12px; line-height: 1.5; color: var(--text-3); }
.month-close .close-steps .pill { min-width: 26px; justify-content: center; }
.table .pill + .btn.ghost { margin-left: 6px; }
.btn abbr { margin-left: -4px; }
.table.payouts td:last-child { min-width: 270px; }
.panel-body > p:only-child { font-size: 14px; line-height: 1.6; color: var(--text-2); }
@media (max-width: 680px) {
  .month-close .close-steps { padding: 0 18px 20px; }
  .panel-head:has(> .actions) { flex-wrap: wrap; }
  .panel-head > .actions { width: 100%; }
}
.user-row > span:not([class]):last-child { margin-right: 48px; }
@media (max-width: 680px) { .user-row > span:not([class]):last-child { margin-right: 0; } }
.member-card .rate-line .btn.ghost { padding-left: 0; padding-right: 0; }
.rights-mini .btn.ghost { padding-left: 0; }
.panel.data-card > .panel-head { padding: 0 0 6px; }
.panel.data-card > .panel-head p { margin-top: 6px; }
.panel.data-card > .notice { margin: 14px 0 0; }
@media (max-width: 680px) { .panel.data-card > .panel-head { padding-bottom: 4px; gap: 12px; } }

/* окно согласий (legal.js): как остальные окна кабинета */
#legal-gate { border-radius: 28px; padding: 28px 30px 30px; width: min(560px, calc(100vw - 32px)); border-color: var(--border-field); box-shadow: 0 24px 100px rgba(20, 25, 40, .2); }
#legal-gate::backdrop { background: var(--surface-3); backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px); }
#legal-gate h2 { font-size: 25px; letter-spacing: -.035em; margin: 0 0 10px; }
#legal-gate > .help { font-size: 13px; line-height: 1.6; color: var(--text-3); margin: 0 0 18px; }
#legal-gate .consent-row { font-size: 13px; }
#legal-gate .consent-group { gap: 14px; margin-bottom: 18px; }
#legal-gate .confirm-actions { margin-top: 18px; }
@media (max-width: 680px) {
  #legal-gate { width: 100%; max-width: none; margin: auto 0 0; max-height: 92dvh; border-radius: 28px 28px 0 0; padding: 24px 22px calc(24px + env(safe-area-inset-bottom, 0px)); }
  #legal-gate h2 { font-size: 24px; }
}

/* фильтры: у месяца, списков и поиска одна высота, подписи стоят на одной линии */
.fld select, .fld input { height: 42px; min-height: 42px; box-sizing: border-box; }
.fld input[type=month], .fld input[type=date] { padding-top: 0; padding-bottom: 0; }
@media (max-width: 680px) {
  table.money-cards td:first-child[data-label]::before { display: none !important; }
}

/* длинные имена, названия и @ники не раздувают страницу */
.cell-person { min-width: 0; }
.cell-person > div { min-width: 0; }
.cell-person .avatar { flex: none; }
.member-card .cell-person > div, .user-row .cell-person > div, .signups .cell-person > div { overflow-wrap: anywhere; }
.table .cell-person > div { max-width: 200px; }
.table .cell-person > div, .table .cell-person small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table td { max-width: 320px; overflow-wrap: break-word; }
.table td:last-child, .table td:has(> .btn:only-child) { max-width: none; }
.breadcrumbs { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar select { max-width: 200px; text-overflow: ellipsis; }
.project-card h3, .brief-card h3, .member-card h3 { overflow-wrap: anywhere; }
@media (max-width: 680px) {
  .chat-row { flex-wrap: wrap; row-gap: 0; }
  .chat-row > span:first-child { flex: 1 1 150px; }
}
@media (max-width: 680px) { .topbar select { max-width: 128px; } }
