/* File lists, XL and contract archives: variable-height rows retain full text.
   Append after styles.css and glass.css. Removal rows keep their collapse rule. */
.files-table-row:not(.file-removing) {
  height: auto;
  max-height: none;
  /* Keep off-screen list virtualization. The remembered auto size is an
     estimate only, never a maximum for visible multiline text. */
  contain-intrinsic-size: auto 96px;
  padding-block: 10px;
}
.files-table-row > *, .files-table-head > * {
  min-width: 0;
}
.files-table-row > div:first-child {
  align-items: flex-start;
}
.files-table-row > div:first-child > span {
  flex: 1 1 0;
  max-width: 100%;
  min-width: 0;
}
.files-table-row > div:first-child > :is(.file-icon, .folder-icon) {
  flex-shrink: 0;
  align-self: flex-start;
}
.files-table-row :is(b, small),
.files-table-row > span,
.files-table-head > span,
.files-table-row :is(.file-contract-tag, .file-xl-tag, .file-reference-tag) {
  max-width: 100%;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.45;
}
.files-table-row > div:first-child > span > b {
  display: block;
  margin: 0;
  line-height: 1.4;
}
.files-table-row > div:first-child > span > small {
  margin-top: 4px;
}
.files-table-row .file-authors {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}
.files-table-row :is(.file-original-path, .archive-counterparty-label, .file-authors-mobile) {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.5;
}
.files-table-row .row-menu {
  align-self: start;
  justify-self: end;
  flex-shrink: 0;
}
.files-table-head, .files-table-row {
  grid-template-columns: minmax(0, 2fr) minmax(0, .8fr) 130px 80px 34px;
}
body.portal-glass :is(.files-table-head, .files-table-row) {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 100px 110px 32px;
}
body.portal-glass .files-table-row:not(.file-removing) {
  padding-block: 10px;
  contain-intrinsic-size: auto 96px;
}
.files-table-row:has(.file-original-path):not(.file-removing),
.files-table-row.is-archive-contract:not(.file-removing),
body.portal-glass .files-table-row:has(.file-original-path):not(.file-removing),
body.portal-glass .files-table-row.is-archive-contract:not(.file-removing) {
  contain-intrinsic-size: auto 144px;
}

/* Wrapping toolbar and folder trails reserve space for the whole label. */
.files-toolbar, body.portal-glass .files-toolbar {
  height: auto;
  flex-wrap: wrap;
  align-items: center;
  row-gap: 8px;
}
.files-toolbar > div:first-child,
body.portal-glass .files-toolbar > div:first-child {
  flex: 1 1 160px;
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
}
.files-toolbar > div:first-child > b,
body.portal-glass .files-toolbar > div:first-child > b {
  min-width: 0;
  max-width: 100%;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.4;
}
.files-toolbar > div:first-child > small {
  overflow-wrap: anywhere;
  line-height: 1.4;
}
.files-toolbar-controls,
body.portal-glass .files-toolbar-controls {
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
}
.file-sort-control,
body.portal-glass .file-sort-control {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
}
.file-sort-control select,
body.portal-glass .file-sort-control select {
  min-width: 0;
  max-width: 100%;
}
.breadcrumbs,
body.portal-glass .breadcrumbs {
  height: auto;
  min-width: 0;
  flex-wrap: wrap;
  overflow: visible;
}
.breadcrumbs > .breadcrumb-link,
body.portal-glass .breadcrumbs > .breadcrumb-link {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.45;
}
.xl-view-intro > div,
.archive-inn-section,
.archive-inn-controls,
.archive-inn-contract-info {
  min-width: 0;
}
.xl-view-intro :is(h2, small),
.archive-inn-contract-info :is(b, small) {
  max-width: 100%;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  line-height: 1.5;
}
.archive-inn-controls {
  flex-wrap: wrap;
}
.archive-inn-controls input {
  min-width: 0;
  max-width: 100%;
}
.archive-inn-contract-actions {
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
}
.archive-inn-contract-actions .secondary-button {
  height: auto;
  min-height: 36px;
  padding-block: 6px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

@media (max-width: 1200px) {
  body.portal-glass :is(.files-table-head, .files-table-row) {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 84px 90px 32px;
  }
}
@media (max-width: 1050px) {
  .files-table-head, .files-table-row {
    grid-template-columns: minmax(0, 1fr) 110px 80px 34px;
  }
  body.portal-glass :is(.files-table-head, .files-table-row) {
    grid-template-columns: minmax(0, 1fr) 84px 86px 32px;
  }
  .archive-inn-contract {
    grid-template-columns: 30px minmax(0, 1fr);
  }
  .archive-inn-contract-actions {
    grid-column: 2;
  }
}
@media (max-width: 700px) {
  body.portal-glass .files-table-row {
    grid-template-columns: minmax(0, 1fr) 44px;
  }
  body.portal-glass .files-table-row .row-menu {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
  }
  /* XL paths and contract details can fill several lines on a phone. Size
     those metadata-heavy rows from the complete text, preserving every label. */
  body.portal-glass .files-table-row:has(.file-original-path):not(.file-removing),
  body.portal-glass .files-table-row.is-archive-contract:not(.file-removing) {
    content-visibility: visible;
    contain-intrinsic-size: none;
  }
}
@media (max-width: 620px) {
  .files-table-row {
    grid-template-columns: minmax(0, 1fr) 44px;
  }
  .files-table-row .row-menu {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
  }
  .files-table-row:has(.file-original-path):not(.file-removing),
  .files-table-row.is-archive-contract:not(.file-removing) {
    content-visibility: visible;
    contain-intrinsic-size: none;
  }
  .files-toolbar > div:first-child,
  body.portal-glass .files-toolbar > div:first-child {
    flex-basis: 100%;
  }
  .files-toolbar-controls,
  body.portal-glass .files-toolbar-controls {
    margin-left: auto;
  }
}

/* Layout corrections against the captured 2026-10-07 runtime assets.
   Append after the portal styles; no editor canvas or application flow changes. */

body.portal-glass .content:has(.mail-workspace,.profile-layout,.admin-section,.trash-section,.history-ai-section) > .page-heading > div:first-child {
  min-width:0;
  overflow-wrap:anywhere;
}
body.portal-glass .content:has(.mail-workspace,.profile-layout,.admin-section,.trash-section,.history-ai-section) > .page-heading .page-actions {
  min-width:0;
  max-width:100%;
  flex-wrap:wrap;
}
body.portal-glass .modal > header { min-width:0;gap:12px; }
body.portal-glass .modal > header > div { min-width:0; }
body.portal-glass .modal > header > button { flex:0 0 auto; }
body.portal-glass .modal > header h2 { overflow-wrap:anywhere; }
body.portal-glass .modal form > footer { flex-wrap:wrap; }
body.portal-glass .modal form > footer > button { max-width:100%;white-space:normal;overflow-wrap:anywhere; }

body.portal-glass .mail-workspace { min-width:0;grid-template-columns:165px 340px minmax(0,1fr); }
body.portal-glass .mail-folders button { min-width:0;grid-template-columns:22px minmax(0,1fr) auto;gap:5px;overflow-wrap:anywhere; }
body.portal-glass .mail-row { grid-template-columns:35px minmax(0,1fr); }
body.portal-glass .mail-row > div,
body.portal-glass .mail-row > div > div { min-width:0; }
body.portal-glass .mail-row b { min-width:0;flex:1 1 auto; }
body.portal-glass .message h2,
body.portal-glass .message-body { overflow-wrap:anywhere; }
body.portal-glass .message-person { grid-template-columns:36px minmax(0,1fr) auto; }
body.portal-glass .message-person > div { min-width:0;overflow-wrap:anywhere; }
body.portal-glass .attachments > :is(a,span) { min-width:0;flex-wrap:wrap;overflow-wrap:anywhere; }
body.portal-glass .message footer > button { max-width:100%;white-space:normal; }

body.portal-glass .profile-layout { grid-template-columns:minmax(0,.65fr) minmax(0,1.35fr); }
body.portal-glass .profile-layout > * { min-width:0; }
body.portal-glass .profile-card > .avatar { flex:0 0 auto; }
body.portal-glass .profile-card > div { min-width:0;overflow-wrap:anywhere; }
body.portal-glass .profile-admin-panel > div { min-width:0;overflow-wrap:anywhere; }
body.portal-glass .admin-summary article { min-width:0;flex-wrap:wrap; }
body.portal-glass .admin-section > header { gap:12px;flex-wrap:wrap; }
body.portal-glass .admin-section > header > div { min-width:0;overflow-wrap:anywhere; }
body.portal-glass .admin-document-registry-grid { grid-template-columns:repeat(auto-fit,minmax(min(310px,100%),1fr)); }
body.portal-glass .admin-user-row > * { min-width:0; }
body.portal-glass .admin-user-main small,
body.portal-glass .admin-security :is(b,small),
body.portal-glass .admin-user-actions > small { overflow-wrap:anywhere; }
body.portal-glass .admin-user-actions { min-width:0; }
body.portal-glass .admin-user-actions button { max-width:100%;white-space:normal; }
body.portal-glass .history-ai-title { flex-wrap:wrap; }
body.portal-glass .history-ai-title > b { flex:1 1 180px; }
body.portal-glass .history-ai-status-label { max-width:100%;overflow-wrap:anywhere; }

/* Tablet main areas are narrower than the viewport because of the sidebar. */
@media (max-width:1200px) {
  body.portal-glass .admin-user-row { grid-template-columns:34px minmax(0,1fr); }
  body.portal-glass .admin-user-row :is(.admin-role,.admin-security,.admin-user-actions) { grid-column:2; }
  body.portal-glass .admin-user-row .admin-role { max-width:100%;white-space:normal;overflow-wrap:anywhere; }
  body.portal-glass .admin-user-main b { white-space:normal;overflow-wrap:anywhere; }
  body.portal-glass .admin-user-actions { justify-content:flex-start; }
  body.portal-glass .trash-row { grid-template-columns:minmax(0,1fr) auto;gap:10px 14px; }
  body.portal-glass .trash-file { grid-column:1 / -1; }
  body.portal-glass .trash-file > i { flex:0 0 auto; }
  body.portal-glass .trash-meta,
  body.portal-glass .trash-path { display:block;grid-column:1; }
  body.portal-glass :is(.trash-file,.trash-meta,.trash-path) :is(b,small,span) { white-space:normal;overflow-wrap:anywhere; }
  body.portal-glass .trash-restore,
  body.portal-glass .trash-admin-only { grid-column:2;grid-row:2 / span 2;align-self:start; }
}

@media (max-width:1050px) {
  body.portal-glass .mail-workspace {
    min-height:0;
    grid-template-columns:135px minmax(0,1fr);
    /* Opening a message must not anchor the outer scroll to the old list row. */
    overflow-anchor:none;
  }
  body.portal-glass .mail-workspace .mail-list { max-height:min(52svh,480px); }
  body.portal-glass .mail-workspace .mail-reader:not(.has-message) { display:none; }
  body.portal-glass .mail-workspace .mail-reader.has-message {
    position:static;
    inset:auto;
    grid-column:1 / -1;
    grid-row:1;
    order:-1;
    display:block;
    min-height:0;
    max-height:min(60svh,540px);
    overflow:auto;
    z-index:auto;
    border-bottom:1px solid var(--line);
  }
  body.portal-glass .profile-layout { grid-template-columns:minmax(0,1fr); }
  body.portal-glass .profile-details dl > div { grid-template-columns:minmax(0,.7fr) minmax(0,1.3fr); }
  body.portal-glass .profile-admin-panel { flex-wrap:wrap; }
  body.portal-glass .profile-admin-actions { max-width:100%; }
  body.portal-glass .history-ai-row { grid-template-columns:38px minmax(0,1fr); }
  body.portal-glass .history-ai-usage { grid-column:2;min-width:0;max-width:100%;justify-items:start;text-align:left; }
  body.portal-glass .history-ai-title > b,
  body.portal-glass .history-ai-cost { white-space:normal;overflow-wrap:anywhere; }
}

@media (max-width:620px) {
  body.portal-glass .mail-workspace { grid-template-columns:minmax(0,1fr); }
  body.portal-glass .message header { padding:18px 14px; }
  body.portal-glass .message-body { min-height:0;padding:18px 14px; }
  body.portal-glass .message-person { grid-template-columns:36px minmax(0,1fr); }
  body.portal-glass .message-person time { grid-column:2; }
  body.portal-glass .message footer { padding:14px; }
  body.portal-glass .attachments { margin-inline:14px;padding:10px; }
  body.portal-glass .profile-details dl > div { grid-template-columns:minmax(0,1fr); }
  body.portal-glass .admin-summary { grid-template-columns:minmax(0,1fr); }
  body.portal-glass .admin-user-actions button {
    flex:1 1 100%;
    overflow-wrap:anywhere;
    line-height:1.4;
    min-height:44px;
    padding-block:8px;
  }
  body.portal-glass .history-ai-row { grid-template-columns:34px minmax(0,1fr); }
  body.portal-glass .trash-row { grid-template-columns:minmax(0,1fr); }
  body.portal-glass .trash-row > * { grid-column:1;grid-row:auto; }
  body.portal-glass .trash-restore { min-width:0;width:auto;justify-self:start; }
  body.portal-glass .trash-restore span { display:inline; }
  body.portal-glass .trash-admin-only { max-width:none;text-align:left; }

  /* The portal's 44px touch minima also apply to the floating messenger.
     Match its explicit dimensions/bases instead of shrinking hit areas. */
  body .so-messenger .so-messenger-icon-button,
  body .so-messenger .so-messenger-add,
  body .so-messenger .so-messenger-send { width:44px;height:44px;flex:0 0 44px; }
  body .so-messenger .so-messenger-composer { align-items:flex-end; }
  body .so-messenger .so-messenger-send { margin-bottom:0; }
  body .so-messenger .so-messenger-section-label { flex-wrap:wrap; }
}
body .so-messenger .so-messenger-message-meta { min-width:0;flex-wrap:wrap;gap:4px 12px; }
body .so-messenger .so-messenger-sender { min-width:0;flex:1 1 80px; }

/* The compact portal is a presentation mode; retained sections stay inert. */
.presentation-hidden[hidden], body.office-simplified [hidden].presentation-hidden { display:none !important; }
body.office-simplified .sidebar-settings { margin:5px 0 0; }
body.office-simplified .sidebar-footer { margin-top:auto; }
body.office-simplified .topbar #create-button { margin-left:auto; }
body.office-simplified .profile-layout { grid-template-columns:minmax(0,1fr);max-width:860px; }
body.office-simplified .profile-layout>* { grid-column:1; }
body.office-simplified .profile-theme { grid-row:1; }
body.office-simplified .profile-security { grid-row:2; }
body.office-simplified .admin-summary { grid-template-columns:repeat(3,minmax(0,1fr)); }
body.office-simplified .admin-user-actions { flex-wrap:wrap; }
body.office-simplified .admin-user-actions>button { white-space:normal; }
.session-recovery { position:fixed;inset:auto 16px 16px;z-index:1300;display:flex;align-items:center;gap:12px;padding:16px;border:1px solid var(--gold-deep,#a98c51);border-radius:14px;background:var(--panel,#fff);color:var(--ink,#1b211d);box-shadow:0 8px 35px #0003; }
.session-recovery>span { flex:1;min-width:0;font-size:13px; }
.session-recovery b { display:block;margin-bottom:4px; }
.session-recovery .secondary-button { flex:none; }
@media (max-width:760px) {
  body.office-simplified.portal-glass .sidebar { display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px;padding:12px; }
  body.office-simplified.portal-glass .sidebar .brand { display:flex;padding:0;grid-column:1; }
  body.office-simplified.portal-glass .sidebar .brand-wordmark-name { font-size:21px; }
  body.office-simplified.portal-glass .sidebar .brand-wordmark-caption { display:none; }
  body.office-simplified.portal-glass .sidebar .nav { display:flex;grid-row:2;grid-column:1;gap:4px;overflow:visible; }
  body.office-simplified.portal-glass .sidebar-settings { grid-row:2;grid-column:2;margin:0; }
  body.office-simplified.portal-glass .sidebar-settings .nav-link { width:auto;font-size:13px;gap:5px;padding:8px; }
  body.office-simplified.portal-glass .sidebar .nav-link { min-height:42px;font-size:13px;padding:8px; }
  body.office-simplified.portal-glass .sidebar .sidebar-footer { display:grid;grid-template-columns:minmax(0,1fr) 28px;grid-column:2;grid-row:1;margin:0;padding:0;border:0;gap:5px;max-width:170px; }
  body.office-simplified.portal-glass .sidebar-footer>.avatar { display:none; }
  body.office-simplified.portal-glass .sidebar-footer>div { min-width:0; }
  body.office-simplified.portal-glass .sidebar-footer b { font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap; }
  body.office-simplified.portal-glass .sidebar-footer small { display:block;font-size:10px; }
  .session-recovery { inset:auto 8px 8px;flex-wrap:wrap;padding:12px;gap:8px; }
  .session-recovery>span { flex-basis:100%; }
  .session-recovery .secondary-button { flex:1;white-space:normal;height:auto;min-height:36px;text-align:center; }
}
/* Notification functionality remains available to retained modules. */
body.office-simplified .ai-inline-bell { display:none !important; }

/* Fresh server role checks hide stale administrative controls in open dialogs. */
body[data-office-administrator="false"] :is([data-admin-create],[data-company-member-role],[data-company-member-status],[data-company-remove-member],#company-employee-form) { display:none !important; }
body.office-simplified .sidebar [hidden] { display:none !important; }
