/* Запросы и переписка кабинета арендатора (решение 215, макеты В1–В6, Д2, Д5, Д6, Д10, Д11, Е1, Е3). Только токены темы
   сайта (app.css), без своих цветов; общий app.css не правится (PLAN §2.2). Подключается при включённом кабинете
   (tenancy.templatetags.cabinet). Таблица на компьютере, карточки на телефоне; поля не мельче 16 px (решение 118). */

.tr-panel { padding: 0; overflow: hidden; }
.tr-panel > .panel-heading, .tr-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 18px 8px; margin: 0; }
.tr-panel > .section-empty { padding: 4px 18px 18px; }

/* Чипы статусов и фильтры */
.tr-filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border); }
.tr-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tr-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface); color: var(--text); font-size: .88rem; font-weight: 550; text-decoration: none;
  white-space: nowrap; }
.tr-chip b { color: var(--muted); font-weight: 650; }
.tr-chip:hover { border-color: var(--accent); }
.tr-chip[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.tr-chip[aria-current="true"] b { color: var(--accent); }
.tr-chip.is-alert b { color: var(--tone-danger-text); }
.tr-selects { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-left: auto; }
.tr-select { min-width: 0; }
.tr-selects .tr-select select { max-width: 200px; }
.tr-select select { min-height: 36px; width: 100%; max-width: 320px; padding: 0 30px 0 12px; border: 1px solid var(--border);
  border-radius: 8px; background-color: var(--surface); color: var(--text); font: inherit; font-size: 1rem; }

/* Список: таблица на компьютере */
.tr-table { --tr-cols: minmax(0, 1.5fr) 170px minmax(0, 1fr); }
.tr-landlord-table { --tr-cols: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, .9fr) 170px 110px; }
.tr-landlord-table.no-contract { --tr-cols: minmax(0, 1.5fr) minmax(0, 1fr) 170px 110px; }
.tr-landlord-table.no-tenant { --tr-cols: minmax(0, 1.5fr) minmax(0, 1fr) 170px 110px; }
.tr-landlord-table.no-contract.no-tenant { --tr-cols: minmax(0, 1.5fr) 170px 110px; }
.tr-thead { display: grid; grid-template-columns: var(--tr-cols); gap: 16px; padding: 10px 18px; border-bottom: 1px solid var(--border);
  background: var(--bg); color: var(--muted); font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.tr-list { margin: 0; padding: 0; list-style: none; }
.tr-row { display: grid; grid-template-columns: var(--tr-cols); gap: 6px 16px; align-items: center; padding: 12px 18px;
  border-top: 1px solid var(--border); }
.tr-row:first-child { border-top: 0; }
.tr-row:nth-child(even) { background: var(--row-alt); }
.tr-row > * { min-width: 0; }
.tr-row.is-new { box-shadow: inset 3px 0 0 var(--accent-fill); }
.tr-row-title { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.tr-row-sub { margin: 2px 0 0; color: var(--muted); font-size: .86rem; }
.tr-cell-last { margin: 0; overflow-wrap: anywhere; }
.tr-cell-label { display: none; }
.tr-no-answer { color: var(--tone-warning-text); font-weight: 600; }
.tr-date-line { display: block; padding: 8px 18px; background: none !important; }
.tr-date-text { display: block; padding: 8px 12px; border: 1px dashed var(--border-strong); border-radius: 10px; color: var(--muted);
  font-size: .88rem; }
.tr-date-day { font-weight: 650; color: var(--text); }
.tr-empty { padding: 26px 22px; text-align: center; }
.tr-empty p { margin: 6px auto 0; max-width: 52ch; color: var(--muted); }
.tr-pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--border); }

/* Карточка запроса — колонки карточек сайта (.residential-card): нить слева, «О запросе» справа; на узком экране нить
   первой (у карточек объекта правая колонка поднимается наверх — здесь нет), панели — во всю ширину, как нить (ревью
   S6, N10: «start» сжимал их по содержимому). */
.tr-card .detail-grid { align-items: start; }
@media (max-width: 780px) { .property-ui.residential-card.tr-card .detail-grid { align-items: stretch; } }
.property-ui.residential-card.tr-card .detail-side { order: 2; }
.property-ui .tr-thread-panel, .property-ui .tr-panel.tr-thread-panel { padding: 16px 18px 18px; }
.property-ui.tr-card .tr-about .overview-facts { padding: 12px 18px 16px; }
/* «Арендатор» (макет Д5): имя ссылкой, «подключён с …» мелко, телефон ссылкой — строками. */
.property-ui.tr-card .tr-tenant-body { display: grid; gap: 4px; padding: 12px 18px 16px; }
.property-ui.tr-card .tr-tenant-body a { font-weight: 600; overflow-wrap: anywhere; }
.property-ui.tr-card .tr-tenant-body small { color: var(--muted); font-size: .86rem; }
.tr-head { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 0 0 12px; color: var(--muted); font-size: .9rem; }
.tr-read { color: var(--muted); font-size: .86rem; }
.tr-read::before { content: "✓✓"; margin-right: 4px; color: var(--accent); font-weight: 700; letter-spacing: -.12em; }
.tr-read.is-unread::before { content: "✓"; color: var(--muted); }
.tr-no-answer-line { margin: -6px 0 12px; color: var(--tone-warning-text); font-size: .88rem; font-weight: 600; }
.tr-thread { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.tr-msg { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.tr-msg.is-mine { background: var(--row-alt); }
.tr-msg.is-system { padding: 8px 12px; border-style: dashed; background: none; color: var(--muted); font-size: .86rem; }
.tr-msg-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 10px; margin-bottom: 4px; }
.tr-msg-who { font-weight: 650; }
.tr-msg-who small { color: var(--muted); font-weight: 500; font-size: .86rem; }
.tr-msg-time { color: var(--muted); font-size: .8rem; }
.tr-msg-text { margin: 0; overflow-wrap: anywhere; }
.tr-files { display: grid; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.tr-file { margin: 0; }
.tr-file .file-meta { min-width: 0; }
.tr-file-name { font-weight: 600; }
.tr-thumb { flex: none; display: block; width: 64px; height: 64px; overflow: hidden; border-radius: 8px; background: var(--bg); }
.tr-thumb img { width: 100%; height: 100%; object-fit: cover; }
.tr-note { margin: 14px 0 0; }
.tr-back { margin: 0 0 6px; font-size: .9rem; }
.tr-thread-title { margin: 0 0 10px; font-size: 1.2rem; }

/* Ответ */
.tr-reply { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.tr-reply .form-field textarea { min-height: 76px; }
.tr-reply-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
/* «Приложить из базы» — по верху рамки выбора файла, а не посередине её высоты (ревью S6, N10). */
.tr-reply-tools { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; }
.tr-reply-send { justify-content: flex-end; }
.tr-after { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; white-space: nowrap; }
.tr-after select { width: auto; min-height: 36px; margin: 0; font-size: 1rem; }
.tr-reopen { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.tr-picker { flex: 1 1 280px; min-width: 0; }
.tr-picker .file-drop .hint { display: block; }
.tr-camera { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; }
.tr-camera[hidden] { display: none; }
.tr-camera svg, .tr-attach > summary svg, .tr-attach-open svg { flex: none; width: 16px; height: 16px; }
.tr-attach-open { display: inline-flex; align-items: center; gap: 6px; }

/* «Приложить из базы»: без скрипта — список в форме, со скриптом — окно (на телефоне — шторка снизу) */
.tr-attach { flex-basis: 100%; }
.tr-attach > summary { display: inline-flex; align-items: center; gap: 6px; list-style: none; cursor: pointer; }
.tr-attach > summary::-webkit-details-marker { display: none; }
.tr-attach[open] > summary { margin-bottom: 8px; }
.tr-attach-sheet { padding: 0; }
.tr-attach > .tr-attach-sheet { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.tr-attach > .tr-attach-sheet .tr-attach-head { display: none; }
.tr-attach-search input { box-sizing: border-box; width: 100%; min-height: 42px; margin: 6px 0 8px; padding: 8px 12px;
  border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; font-size: 1rem; }
.tr-attach-list { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.tr-attach-group { margin: 0; padding: 10px 12px 4px; color: var(--muted); font-size: .75rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; }
.tr-attach-row { display: grid; grid-template-columns: 20px 34px minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px 12px;
  cursor: pointer; }
.tr-attach-row:has(input:checked) { background: var(--accent-soft); }
.tr-attach-row:has(input:disabled) { cursor: default; opacity: .75; }
.tr-attach-row input { width: 18px; height: 18px; margin: 0; }
.tr-attach-row .file-icon { width: 30px; height: 30px; font-size: .75rem; }
.tr-attach-text { min-width: 0; }
.tr-attach-text strong { display: block; overflow-wrap: anywhere; }
.tr-attach-text small { display: block; color: var(--muted); }
.tr-hidden-file { display: inline-flex; margin-top: 4px; padding: 2px 8px; border-radius: 999px; background: var(--tone-warning-soft);
  color: var(--tone-warning-text); font-size: .8rem; font-weight: 600; }
.tr-show-receipts { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px; margin: 10px 0 0; padding: 10px 12px;
  border-radius: 10px; background: var(--tone-warning-soft); }
.tr-show-receipts small { display: block; color: var(--muted); }
.tr-attach-empty { margin: 4px 0; color: var(--muted); }
.tr-attach-actions { display: flex; justify-content: flex-end; gap: 10px; }
.tr-attach-dialog .tr-attach-sheet { padding-top: 4px; }
.tr-attach-dialog .tr-attach-actions { position: sticky; bottom: -16px; margin: 14px -20px -16px; padding: 12px 20px 16px;
  border-top: 1px solid var(--border); background: var(--surface); }
.tr-chosen { margin-top: 0; }
.tr-chosen:empty { display: none; }

/* Ремонт */
.property-ui .tr-repair { margin-top: 16px; }
.tr-repair form { padding: 4px 18px 18px; }
.tr-repair-grid { align-items: start; }
.tr-when { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 10px; }
.tr-segment { display: inline-flex; padding: 2px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); margin: 0; }
.tr-segment label { display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border-radius: 8px; color: var(--muted);
  font-size: .9rem; font-weight: 600; cursor: pointer; }
.tr-segment input { position: absolute; opacity: 0; pointer-events: none; }
.tr-segment label:has(input:checked) { background: var(--accent-soft); color: var(--accent); }
.tr-segment label:has(input:focus-visible) { outline: 2px solid var(--accent); }
.tr-repair-list { margin: 0; padding: 0 18px 14px; list-style: none; }
.tr-repair-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0;
  border-top: 1px solid var(--border); }
.tr-repair-row:first-child { border-top: 0; }
.tr-repair-main { min-width: 0; }
.tr-repair-main a { font-weight: 600; }
.tr-repair-main small { display: block; color: var(--muted); }

/* Новый запрос по шагам */
.tr-kind-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tr-only-contract { margin: 0 0 14px; }
.tr-only-contract .muted { display: block; font-size: .86rem; }
.tr-choice { margin: 0 0 14px; padding: 0; border: 0; }
.tr-radio { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.tr-switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 14px; padding: 12px 0;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); cursor: pointer; }
.tr-switch small { display: block; color: var(--muted); font-size: .86rem; }
.tr-switch input { flex: none; position: relative; width: 44px; height: 26px; margin: 0; border-radius: 999px;
  background: var(--switch-off, var(--border-strong)); appearance: none; cursor: pointer; transition: background .15s; }
.tr-switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, .2); transition: left .15s; }
.tr-switch input:checked { background: var(--accent-fill); }
.tr-switch input:checked::after { left: 21px; }
.tr-switch input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tr-attach-field { display: grid; gap: 6px; margin-top: 4px; }
.tr-attach-label { font-weight: 600; }
.tr-summary { margin: 0 0 12px; padding: 4px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--row-alt); }
.tr-summary div { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.tr-summary div:first-child { border-top: 0; }
.tr-summary dt { color: var(--muted); font-size: .9rem; }
.tr-summary dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.tr-send-note { margin: 0; }

/* Телефон: строки — карточки, чипы переносятся, окно «Приложить из базы» — шторка снизу (как окна сайта) */
@media (max-width: 640px) {
  .tr-thead { display: none; }
  .tr-row { grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 12px 14px; }
  .tr-row:nth-child(even) { background: none; }
  .tr-cell-label { display: inline; color: var(--muted); }
  .tr-filters { padding: 12px 14px; }
  .tr-selects { margin-left: 0; width: 100%; }
  .tr-filters > .tr-select, .tr-selects > .tr-select { flex: 1 1 100%; }
  .tr-select select, .tr-selects .tr-select select { max-width: 100%; }
  .tr-panel > .panel-heading, .tr-panel-heading { padding: 14px 14px 6px; }
  .tr-date-line { padding: 8px 14px; }
  .tr-thread-panel { padding: 14px; }
  .tr-reply-actions { align-items: stretch; }
  .tr-reply-send { flex-direction: column; align-items: stretch; }
  .tr-reply-send .button, .tr-reply-actions > .button { width: 100%; justify-content: center; }
  .tr-summary div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .tr-kind-grid { grid-template-columns: minmax(0, 1fr); }
  .tr-when { grid-template-columns: minmax(0, 1fr) 96px; }
  .tr-repair form { padding: 4px 14px 14px; }
  .tr-repair-list { padding: 0 14px 12px; }
}
