/* Общая папка аренды (решение 214, макеты Б8, Б9, Б10, Б13, Д7). Подключается при включённом кабинете
   (tenancy.templatetags.cabinet, STYLE_APPS); общий app.css не правится (PLAN §2.2). Цвета — токены сайта. */

/* --- Папка: разделы и строки --------------------------------------------------------------------------------------- */
.tdocs-folder, .tdocs-panel, .tdocs-invoices { padding-bottom: 6px; }
.tdocs-lede { margin: 14px 20px 4px; color: var(--muted); max-width: 72ch; }
.tdocs-section { padding: 0 20px; }
.tdocs-section + .tdocs-section { border-top: 1px solid var(--border); }
.tdocs-section-title {
  margin: 16px 0 4px; color: var(--muted); font-size: .76rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase;
}
.tdocs-list { list-style: none; margin: 0; padding: 0; }
.tdocs-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; min-width: 0; }
.tdocs-row + .tdocs-row { border-top: 1px solid var(--border-soft, var(--border)); }
.tdocs-badge {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px;
  background: var(--tone-neutral); color: #fff; font-size: .75rem; font-weight: 700; letter-spacing: .02em;
}
.tdocs-badge[data-kind=PDF] { background: #b42318; }
.tdocs-badge[data-kind=DOCX], .tdocs-badge[data-kind=DOC] { background: #2458d6; }
.tdocs-badge[data-kind=JPG], .tdocs-badge[data-kind=JPEG], .tdocs-badge[data-kind=PNG] { background: #1b7a3d; }
.tdocs-main { flex: 1; min-width: 0; }
.tdocs-title { display: block; font-weight: 600; overflow-wrap: anywhere; }
a.tdocs-title { text-decoration: none; }
a.tdocs-title:hover { text-decoration: underline; }
.tdocs-meta, .tdocs-note { margin: 2px 0 0; color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.tdocs-note { color: var(--text); }
.tdocs-side { flex: none; display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.tdocs-inline { display: inline; margin: 0; }
.tdocs-empty { margin: 4px 0 14px; color: var(--muted); }
.tdocs-count {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; margin-left: 6px;
  border-radius: 11px; background: var(--accent); color: #fff; font-size: .78rem; font-weight: 700; vertical-align: 2px;
}
/* Список прямо в панели — с отступом панели; в разделе (.tdocs-section) отступ уже у раздела. */
.tdocs-panel > .tdocs-list, .tdocs-uploaded > .tdocs-list { padding: 0 20px; }

/* «Загружено арендатором» — над плитками документов договора (макет Д7): сетка колонки карточки сохраняет порядок. */
.tdocs-uploaded { order: -1; }

/* --- «Счета и акты» (Б13) --------------------------------------------------------------------------------------------- */
.tdocs-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 20px 14px; border-bottom: 1px solid var(--border); }
.tdocs-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--border);
  border-radius: 999px; color: var(--text); text-decoration: none; font-weight: 600; font-size: .9rem;
}
.tdocs-chip.is-current { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.tdocs-chip-count { color: var(--muted); font-weight: 600; }
.tdocs-chip.is-current .tdocs-chip-count { color: inherit; }
.tdocs-table { width: 100%; border-collapse: collapse; }
.tdocs-table th {
  padding: 10px 12px; background: var(--row-alt); color: var(--muted); font-size: .75rem; font-weight: 700;
  letter-spacing: .08em; text-align: left; text-transform: uppercase;
}
.tdocs-table td { padding: 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.tdocs-table th:first-child, .tdocs-table td:first-child { padding-left: 20px; }
.tdocs-table th:last-child, .tdocs-table td:last-child { padding-right: 20px; }
.tdocs-cell-title .tdocs-meta { display: block; }
.tdocs-cell-amount { font-weight: 700; white-space: nowrap; }
.tdocs-cell-actions { text-align: right; white-space: nowrap; }
.tdocs-cell-actions > * + * { margin-left: 6px; }

/* --- Загрузка по шагам (Б9) ------------------------------------------------------------------------------------------- */
.tdocs-kinds { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tdocs-kind { position: relative; padding-left: 64px; min-height: 64px; }
.tdocs-kind-icon {
  position: absolute; left: 14px; top: 14px; display: grid; place-items: center; width: 40px; height: 40px;
  border-radius: 10px; background: var(--accent-soft); color: var(--accent);
}
.tdocs-file-pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.tdocs-file-pick .file-drop { margin: 0; }
.tdocs-camera { display: none !important; }
@media (pointer: coarse) { .tdocs-camera { display: flex !important; } }
.tdocs-chosen, .tdocs-file-pick .error { grid-column: 1 / -1; }
.tdocs-chosen { display: flex; align-items: center; gap: 12px; margin: 0; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; font-weight: 600; overflow-wrap: anywhere; }
.tdocs-chosen[hidden] { display: none; }
.tdocs-readings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 12px; }
.tdocs-readings.pf-off { display: none; }
.tdocs-review { display: grid; margin: 0 0 12px; padding: 4px 18px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--row-alt); }
.tdocs-review > div { padding: 12px 0; }
.tdocs-review > div + div { border-top: 1px solid var(--border); }
.tdocs-review dt { color: var(--muted); font-size: .88rem; }
.tdocs-review dd { margin: 4px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.tdocs-review-note { color: var(--muted); }

/* --- Карточка документа (Б10) и окна ------------------------------------------------------------------------------- */
.tdocs-preview { display: grid; place-items: center; min-height: 360px; margin: 18px 18px 0; border-radius: 10px;
  background: var(--preview-bg, var(--row-alt)); overflow: hidden; }
.tdocs-preview iframe { width: 100%; height: 70vh; min-height: 420px; border: 0; background: #fff; }
.tdocs-preview img { display: block; max-width: 100%; max-height: 70vh; object-fit: contain; }
.tdocs-preview-actions { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px 18px 18px; }
/* Строка вместо файла (нет предпросмотра, файл удалён) и содержимое карточки арендодателя — по краю заголовка панели. */
.tdocs-preview-panel > .tdocs-empty { margin: 0; padding: 18px 22px; }
.tdocs-card-body { display: grid; gap: 8px; padding: 14px 22px 18px; }
.tdocs-card-body > * { margin: 0; }
.tdocs-card-body .overview-facts { padding: 0; }
.tdocs-card-body + .tdocs-preview-actions { padding: 0 22px 18px; }
.tdocs-answer p { margin: 0 20px 10px; }
.tdocs-answer .hint { display: block; margin: 8px 20px 16px; color: var(--muted); }
.tdocs-answer-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 20px; }
.tdocs-answer-buttons .tdocs-inline { display: contents; }
.tdocs-answer > .tdocs-inline { display: flex; margin: 0 20px; }
.tdocs-answer-state { display: flex; align-items: center; gap: 8px; }
.tdocs-others { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.tdocs-mark-doc { margin: 0 0 10px; overflow-wrap: anywhere; }
.tdocs-history { list-style: none; margin: 0; padding: 4px 20px 16px; }
.tdocs-history li { position: relative; display: grid; gap: 2px; padding: 0 0 14px 20px; }
.tdocs-history li::before { content: ""; position: absolute; left: 2px; top: 6px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); }
.tdocs-history li + li::after { content: ""; position: absolute; left: 5px; top: -12px; height: 18px; border-left: 1px solid var(--border); }
.tdocs-history-title { font-weight: 600; }
.tdocs-history-meta, .tdocs-history-file { color: var(--muted); font-size: .86rem; }
.tdocs-history-text { overflow-wrap: anywhere; }

/* Карточка документа на узком экране: колонки карточки жилья становятся одним столбцом (residential.css, 780 px), а
   выравнивание сетки карточки (align-items: start) сжимало панели «О документе» и «История» по содержимому. */
@media (max-width: 780px) {
  .property-ui .detail-grid.tdocs-card { align-items: stretch; }
}

/* --- Телефон --------------------------------------------------------------------------------------------------------- */
@media (max-width: 700px) {
  .tdocs-section { padding-left: 16px; padding-right: 16px; }
  .tdocs-lede { margin: 12px 16px 4px; }
  .tdocs-panel > .tdocs-list, .tdocs-uploaded > .tdocs-list { padding: 0 16px; }
  .tdocs-preview-panel > .tdocs-empty { padding: 14px 16px; }
  .tdocs-card-body { padding: 12px 16px 16px; }
  .tdocs-card-body + .tdocs-preview-actions { padding: 0 16px 16px; }
  .tdocs-row { flex-wrap: wrap; align-items: flex-start; }
  .tdocs-main { flex: 1 1 calc(100% - 60px); }
  .tdocs-side { flex: 1 1 100%; justify-content: flex-start; padding-left: 54px; }
  .tdocs-file-pick { grid-template-columns: minmax(0, 1fr); }
  .tdocs-readings { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .tdocs-chips { padding: 0 16px 12px; }
  /* Таблица счетов и актов — карточками (решение 118). */
  .tdocs-table thead { display: none; }
  .tdocs-table, .tdocs-table tbody, .tdocs-table tr, .tdocs-table td { display: block; width: 100%; }
  .tdocs-table tr { padding: 12px 16px; border-top: 1px solid var(--border); }
  .tdocs-table td { padding: 2px 0; border: 0; }
  .tdocs-table th:first-child, .tdocs-table td:first-child, .tdocs-table th:last-child, .tdocs-table td:last-child { padding-left: 0; padding-right: 0; }
  .tdocs-table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-weight: 400; }
  .tdocs-cell-actions { text-align: left; padding-top: 8px; }
  .tdocs-preview { margin: 12px 12px 0; min-height: 240px; }
  .tdocs-preview iframe { height: 60vh; min-height: 320px; }
}
