.advanced-list-page {
  display: grid;
  gap: 16px;
}

@media (max-width: 720px) {
  dialog.document-upload-dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
  }

  .document-upload-form {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .document-upload-modal-head {
    padding: calc(16px + env(safe-area-inset-top)) 16px 14px;
  }

  .document-upload-modal-body {
    padding: 16px;
    gap: 14px;
  }

  .document-upload-modal-footer {
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  }

  .document-dialog-grid {
    grid-template-columns: 1fr;
  }

  .document-upload-file {
    grid-template-columns: 38px minmax(0, 1fr) 32px;
    display: grid;
  }

  .document-upload-file button {
    width: 32px;
    height: 32px;
  }
}

/* Documents page hotfix: keep the right sidebar inside the grid and make file
   previews explicit, so a failed embedded PDF never leaves an empty white pane. */
.documents-page {
  max-width: 1600px;
  overflow-x: clip;
}

.documents-layout {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px) !important;
  gap: 22px !important;
}

.documents-main,
.documents-side {
  min-width: 0;
}

.documents-side {
  position: static !important;
  width: auto !important;
  max-width: none !important;
  align-self: start;
}

.document-upload-card,
.document-filter-panel,
.document-list-card {
  min-width: 0;
}

.document-filter-panel {
  grid-template-columns: minmax(220px, 1.35fr) repeat(3, minmax(150px, .8fr)) auto !important;
}

.document-full-preview {
  align-items: stretch !important;
  justify-items: stretch !important;
  place-items: stretch !important;
  min-height: 68vh;
  padding: 0;
}

.document-preview-shell {
  width: 100%;
  min-height: 68vh;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: #f8fbfd;
}

.document-preview-frame {
  width: 100%;
  min-height: 68vh;
  height: 72vh;
  border: 0;
  background: #fff;
}

.document-preview-image {
  width: 100%;
  max-width: 100%;
  height: 68vh;
  object-fit: contain;
  background: #fff;
}

.document-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.92);
}

.document-preview-empty {
  width: min(520px, calc(100% - 36px));
  align-self: center;
  justify-self: center;
  display: grid;
  gap: 10px;
  text-align: center;
  padding: 22px;
  border: 1px dashed rgba(113,128,154,.34);
  border-radius: 18px;
  background: rgba(255,255,255,.78);
  color: var(--text);
}

.document-preview-empty p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.document-preview-empty div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

[data-theme="dark"] .document-preview-shell,
[data-theme="dark"] .document-preview-image {
  background: #0f1b2a;
}

[data-theme="dark"] .document-preview-actions {
  background: rgba(18,30,45,.92);
}

[data-theme="dark"] .document-preview-empty {
  background: rgba(28,42,60,.72);
}

@media (max-width: 1240px) {
  .documents-layout {
    grid-template-columns: 1fr !important;
  }

  .documents-side {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .documents-side {
    grid-template-columns: 1fr !important;
  }

  .document-filter-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .document-filter-panel label:first-child,
  .document-filter-panel button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .document-filter-panel {
    grid-template-columns: 1fr !important;
  }

  .document-preview-shell,
  .document-preview-frame,
  .document-preview-image {
    min-height: 60vh;
    height: 60vh;
  }

  .document-preview-actions {
    justify-content: stretch;
  }

  .document-preview-actions button {
    flex: 1 1 150px;
  }
}

@media (max-width: 768px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .content.tasks-list-page {
    width: 100%;
    min-width: 0 !important;
    max-width: 100% !important;
    padding: 14px 12px 88px !important;
    gap: 12px !important;
    overflow-x: clip;
  }

  .tasks-list-page .list-filter-panel,
  .tasks-list-page .list-table-card,
  .tasks-list-page .list-row-card {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  .tasks-list-page .list-filter-panel {
    padding: 14px !important;
    border-radius: 18px !important;
    overflow: hidden;
  }

  .tasks-list-page .list-filter-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 0 !important;
  }

  .tasks-list-page .list-filter-grid > label:not(.task-search-field),
  .tasks-list-page .list-filter-grid > .reset-filters {
    display: none !important;
  }

  .tasks-list-page .task-search-field {
    display: grid !important;
    grid-column: 1 !important;
    width: 100%;
    gap: 8px;
  }

  .tasks-list-page .task-search-field input {
    height: 50px !important;
    border-radius: 14px !important;
    font-size: 14px !important;
  }

  .tasks-list-page .mobile-task-filter-row {
    display: flex !important;
    margin-top: 12px;
  }

  .tasks-list-page .mobile-filter-trigger {
    width: 100%;
    height: 46px;
    border-radius: 14px;
    justify-content: center;
  }

  .tasks-list-page .summary-strip {
    display: flex !important;
    grid-template-columns: none !important;
    gap: 10px !important;
    margin: 14px -14px 0 !important;
    padding: 14px 14px 2px !important;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    border-top: 1px solid var(--line);
    -webkit-overflow-scrolling: touch;
  }

  .tasks-list-page .summary-strip::-webkit-scrollbar {
    display: none;
  }

  .tasks-list-page .summary-card {
    flex: 0 0 128px !important;
    width: 128px !important;
    min-width: 128px !important;
    min-height: 78px !important;
    padding: 12px !important;
    scroll-snap-align: start;
  }

  .tasks-list-page .list-toolbar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 10px !important;
    align-items: center !important;
    margin-top: 14px !important;
  }

  .tasks-list-page .list-toolbar .view-toggle {
    display: none !important;
  }

  .tasks-list-page .task-sort-select {
    position: relative;
    display: block !important;
    min-width: 0 !important;
    color: var(--muted);
    font-size: 13px !important;
    font-weight: 800;
  }

  .tasks-list-page .task-sort-select span {
    display: block !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tasks-list-page .task-sort-select select {
    position: absolute;
    inset: -10px 0;
    width: 100%;
    opacity: 0;
  }

  .tasks-list-page .list-toolbar > label:last-child {
    display: flex !important;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    white-space: nowrap;
    font-size: 0;
  }

  .tasks-list-page .list-toolbar > label:last-child::before {
    content: "Показать";
    font-size: 12px;
    color: var(--muted);
    font-weight: 800;
  }

  .tasks-list-page .list-toolbar > label:last-child select {
    width: 64px !important;
    min-width: 64px !important;
    height: 38px !important;
    border-radius: 12px !important;
  }

  .tasks-list-page .list-table-card {
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
  }

  .tasks-list-page .task-list-row {
    width: 100% !important;
    max-width: 100% !important;
    display: grid !important;
    grid-template-columns: 14px minmax(0, 1fr) 36px !important;
    gap: 10px !important;
    align-items: start !important;
    min-height: 0 !important;
    padding: 16px !important;
    margin: 0 0 12px !important;
    border-radius: 18px !important;
    overflow: hidden !important;
  }

  .tasks-list-page .task-list-row .row-check {
    display: none !important;
  }

  .tasks-list-page .task-list-row .priority-dot {
    grid-column: 1 !important;
    grid-row: 1 !important;
    margin-top: 7px !important;
  }

  .tasks-list-page .task-list-row .row-main {
    grid-column: 2 !important;
    grid-row: 1 !important;
    min-width: 0 !important;
  }

  .tasks-list-page .task-list-row .row-main b {
    display: block;
    font-size: 15px !important;
    line-height: 1.25 !important;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .tasks-list-page .task-list-row .row-main p {
    margin-top: 7px !important;
    font-size: 12px !important;
    line-height: 1.35 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .tasks-list-page .task-list-row .row-main small {
    display: block !important;
    margin-top: 8px !important;
    font-size: 12px !important;
  }

  .tasks-list-page .task-list-row .row-menu {
    grid-column: 3 !important;
    grid-row: 1 !important;
    width: 34px !important;
    height: 34px !important;
    justify-self: end !important;
    border-radius: 12px !important;
  }

  .tasks-list-page .task-list-row .row-person,
  .tasks-list-page .task-list-row .row-center,
  .tasks-list-page .task-list-row .row-date,
  .tasks-list-page .task-list-row .status-badge {
    grid-column: 2 / 4 !important;
    min-width: 0 !important;
    justify-self: start !important;
  }

  .tasks-list-page .task-list-row .row-person {
    grid-row: 2 !important;
    display: flex !important;
    gap: 6px;
    align-items: baseline;
    margin-top: 4px !important;
  }

  .tasks-list-page .task-list-row .row-person span {
    display: none !important;
  }

  .tasks-list-page .task-list-row .row-person::before {
    content: "👤";
    font-size: 13px;
  }

  .tasks-list-page .task-list-row .row-person b {
    font-size: 13px !important;
    white-space: nowrap;
  }

  .tasks-list-page .task-list-row .row-person small {
    display: block !important;
    min-width: 0;
    font-size: 11px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tasks-list-page .task-list-row .row-center {
    grid-row: 3 !important;
    margin-top: 4px !important;
  }

  .tasks-list-page .task-list-row .row-date {
    grid-row: 4 !important;
    margin-top: 4px !important;
    font-size: 12px !important;
  }

  .tasks-list-page .task-list-row .status-badge {
    grid-row: 5 !important;
    margin-top: 6px !important;
    font-size: 12px !important;
    padding: 7px 10px !important;
  }

  .tasks-list-page .list-pagination {
    display: grid !important;
    gap: 10px !important;
    padding: 8px 4px 0 !important;
    text-align: center;
  }

  .tasks-list-page .list-pagination div {
    justify-content: center;
  }
}

/* Final documents layout override. This stays at EOF because older bundled
   document/list styles above are repeated and can otherwise win in cascade. */
.documents-page{max-width:1600px;overflow-x:clip}
.documents-layout{display:grid!important;grid-template-columns:minmax(0,1fr) minmax(260px,320px)!important;gap:22px!important;align-items:start!important}
.documents-main,.documents-side,.document-upload-card,.document-filter-panel,.document-list-card{min-width:0}
.documents-side{position:static!important;width:auto!important;max-width:none!important;align-self:start!important}
.document-filter-panel{grid-template-columns:minmax(220px,1.35fr) repeat(3,minmax(150px,.8fr)) auto!important}
.document-full-preview{align-items:stretch!important;justify-items:stretch!important;place-items:stretch!important;min-height:68vh;padding:0}
.document-preview-shell{width:100%;min-height:68vh;display:grid;grid-template-rows:minmax(0,1fr) auto;background:#f8fbfd}
.document-preview-frame{width:100%;min-height:68vh;height:72vh;border:0;background:#fff}
.document-preview-image{width:100%;max-width:100%;height:68vh;object-fit:contain;background:#fff}
.document-preview-actions{display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end;padding:12px 14px;border-top:1px solid var(--line);background:rgba(255,255,255,.92)}
.document-preview-empty{width:min(520px,calc(100% - 36px));align-self:center;justify-self:center;display:grid;gap:10px;text-align:center;padding:22px;border:1px dashed rgba(113,128,154,.34);border-radius:18px;background:rgba(255,255,255,.78);color:var(--text)}
.document-preview-empty p{margin:0;color:var(--muted);line-height:1.45}.document-preview-empty div{display:flex;flex-wrap:wrap;gap:8px;justify-content:center}
[data-theme="dark"] .document-preview-shell,[data-theme="dark"] .document-preview-image{background:#0f1b2a}[data-theme="dark"] .document-preview-actions{background:rgba(18,30,45,.92)}[data-theme="dark"] .document-preview-empty{background:rgba(28,42,60,.72)}
@media (max-width:1240px){.documents-layout{grid-template-columns:1fr!important}.documents-side{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))}}
@media (max-width:980px){.documents-side{grid-template-columns:1fr!important}.document-filter-panel{grid-template-columns:repeat(2,minmax(0,1fr))!important}.document-filter-panel label:first-child,.document-filter-panel button{grid-column:1/-1}}
@media (max-width:720px){.document-filter-panel{grid-template-columns:1fr!important}.document-preview-shell,.document-preview-frame,.document-preview-image{min-height:60vh;height:60vh}.document-preview-actions{justify-content:stretch}.document-preview-actions button{flex:1 1 150px}}

/* Mobile Tasks override must be last: it prevents the shared desktop list
   rules from squeezing the Tasks page into a mini desktop table on phones. */
@media (max-width: 768px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .content.tasks-list-page {
    width: 100%;
    min-width: 0 !important;
    max-width: 100% !important;
    padding: 14px 12px 88px !important;
    gap: 12px !important;
    overflow-x: clip;
  }

  .tasks-list-page .list-filter-panel,
  .tasks-list-page .list-table-card,
  .tasks-list-page .list-row-card {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  .tasks-list-page .list-filter-panel {
    padding: 14px !important;
    border-radius: 18px !important;
    overflow: hidden;
  }

  .tasks-list-page .list-filter-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 0 !important;
  }

  .tasks-list-page .list-filter-grid > label:not(.task-search-field),
  .tasks-list-page .list-filter-grid > .reset-filters {
    display: none !important;
  }

  .tasks-list-page .task-search-field {
    display: grid !important;
    grid-column: 1 !important;
    width: 100%;
    gap: 8px;
  }

  .tasks-list-page .task-search-field input {
    height: 50px !important;
    border-radius: 14px !important;
    font-size: 14px !important;
  }

  .tasks-list-page .mobile-task-filter-row {
    display: flex !important;
    margin-top: 12px;
  }

  .tasks-list-page .mobile-filter-trigger {
    width: 100%;
    height: 46px;
    border-radius: 14px;
    justify-content: center;
  }

  .tasks-list-page .summary-strip {
    display: flex !important;
    grid-template-columns: none !important;
    gap: 10px !important;
    margin: 14px -14px 0 !important;
    padding: 14px 14px 2px !important;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    border-top: 1px solid var(--line);
    -webkit-overflow-scrolling: touch;
  }

  .tasks-list-page .summary-strip::-webkit-scrollbar {
    display: none;
  }

  .tasks-list-page .summary-card {
    flex: 0 0 128px !important;
    width: 128px !important;
    min-width: 128px !important;
    min-height: 78px !important;
    padding: 12px !important;
    scroll-snap-align: start;
  }

  .tasks-list-page .list-toolbar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 10px !important;
    align-items: center !important;
    margin-top: 14px !important;
  }

  .tasks-list-page .list-toolbar .view-toggle {
    display: none !important;
  }

  .tasks-list-page .task-sort-select {
    position: relative;
    display: block !important;
    min-width: 0 !important;
    color: var(--muted);
    font-size: 13px !important;
    font-weight: 800;
  }

  .tasks-list-page .task-sort-select span {
    display: block !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tasks-list-page .task-sort-select select {
    position: absolute;
    inset: -10px 0;
    width: 100%;
    opacity: 0;
  }

  .tasks-list-page .list-toolbar > label:last-child {
    display: flex !important;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    white-space: nowrap;
    font-size: 0;
  }

  .tasks-list-page .list-toolbar > label:last-child::before {
    content: "Показать";
    font-size: 12px;
    color: var(--muted);
    font-weight: 800;
  }

  .tasks-list-page .list-toolbar > label:last-child select {
    width: 64px !important;
    min-width: 64px !important;
    height: 38px !important;
    border-radius: 12px !important;
  }

  .tasks-list-page .list-table-card {
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
  }

  .tasks-list-page .task-list-row {
    width: 100% !important;
    max-width: 100% !important;
    display: grid !important;
    grid-template-columns: 14px minmax(0, 1fr) 36px !important;
    gap: 10px !important;
    align-items: start !important;
    min-height: 0 !important;
    padding: 16px !important;
    margin: 0 0 12px !important;
    border-radius: 18px !important;
    overflow: hidden !important;
  }

  .tasks-list-page .task-list-row .row-check {
    display: none !important;
  }

  .tasks-list-page .task-list-row .priority-dot {
    grid-column: 1 !important;
    grid-row: 1 !important;
    margin-top: 7px !important;
  }

  .tasks-list-page .task-list-row .row-main {
    grid-column: 2 !important;
    grid-row: 1 !important;
    min-width: 0 !important;
  }

  .tasks-list-page .task-list-row .row-main b {
    display: block;
    font-size: 15px !important;
    line-height: 1.25 !important;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .tasks-list-page .task-list-row .row-main p {
    margin-top: 7px !important;
    font-size: 12px !important;
    line-height: 1.35 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .tasks-list-page .task-list-row .row-main small {
    display: block !important;
    margin-top: 8px !important;
    font-size: 12px !important;
  }

  .tasks-list-page .task-list-row .row-menu {
    grid-column: 3 !important;
    grid-row: 1 !important;
    width: 34px !important;
    height: 34px !important;
    justify-self: end !important;
    border-radius: 12px !important;
  }

  .tasks-list-page .task-list-row .row-person,
  .tasks-list-page .task-list-row .row-center,
  .tasks-list-page .task-list-row .row-date,
  .tasks-list-page .task-list-row .status-badge {
    grid-column: 2 / 4 !important;
    min-width: 0 !important;
    justify-self: start !important;
  }

  .tasks-list-page .task-list-row .row-person {
    grid-row: 2 !important;
    display: flex !important;
    gap: 6px;
    align-items: baseline;
    margin-top: 4px !important;
  }

  .tasks-list-page .task-list-row .row-person span {
    display: none !important;
  }

  .tasks-list-page .task-list-row .row-person::before {
    content: "👤";
    font-size: 13px;
  }

  .tasks-list-page .task-list-row .row-person b {
    font-size: 13px !important;
    white-space: nowrap;
  }

  .tasks-list-page .task-list-row .row-person small {
    display: block !important;
    min-width: 0;
    font-size: 11px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tasks-list-page .task-list-row .row-center {
    grid-row: 3 !important;
    margin-top: 4px !important;
  }

  .tasks-list-page .task-list-row .row-date {
    grid-row: 4 !important;
    margin-top: 4px !important;
    font-size: 12px !important;
  }

  .tasks-list-page .task-list-row .status-badge {
    grid-row: 5 !important;
    margin-top: 6px !important;
    font-size: 12px !important;
    padding: 7px 10px !important;
  }

  .tasks-list-page .list-pagination {
    display: grid !important;
    gap: 10px !important;
    padding: 8px 4px 0 !important;
    text-align: center;
  }

  .tasks-list-page .list-pagination div {
    justify-content: center;
  }
}

/* Final mobile-first composition for the Tasks page.
   This block intentionally lives at the end of the file so it wins over the
   older shared advanced-list mobile rules above. */
@media (max-width: 768px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .content.tasks-list-page,
  .tasks-list-page,
  .tasks-list-page .list-filter-panel,
  .tasks-list-page .list-table-card,
  .tasks-list-page .list-row-card {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  .content.tasks-list-page {
    width: 100%;
    padding: 14px 12px 88px !important;
    gap: 12px !important;
    overflow-x: clip;
  }

  .tasks-list-page .list-filter-panel {
    padding: 14px !important;
    border-radius: 18px !important;
    overflow: hidden;
  }

  .tasks-list-page .list-filter-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 0 !important;
  }

  .tasks-list-page .list-filter-grid > label:not(.task-search-field),
  .tasks-list-page .list-filter-grid > .reset-filters {
    display: none !important;
  }

  .tasks-list-page .task-search-field {
    display: grid !important;
    grid-column: 1 !important;
    width: 100%;
    gap: 8px;
  }

  .tasks-list-page .task-search-field span {
    display: block !important;
    font-size: 13px !important;
    line-height: 1.2;
  }

  .tasks-list-page .task-search-field input {
    width: 100%;
    height: 50px !important;
    border-radius: 14px !important;
    font-size: 14px !important;
  }

  .tasks-list-page .mobile-task-filter-row {
    display: flex !important;
    margin-top: 12px;
  }

  .tasks-list-page .mobile-filter-trigger {
    width: 100%;
    height: 46px;
    border-radius: 14px;
    font-size: 14px;
    justify-content: center;
  }

  .tasks-list-page .summary-strip {
    display: flex !important;
    grid-template-columns: none !important;
    gap: 10px !important;
    margin: 14px -14px 0 !important;
    padding: 14px 14px 2px !important;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    border-top: 1px solid var(--line);
    -webkit-overflow-scrolling: touch;
  }

  .tasks-list-page .summary-strip::-webkit-scrollbar {
    display: none;
  }

  .tasks-list-page .summary-card {
    flex: 0 0 128px !important;
    width: 128px !important;
    min-width: 128px !important;
    min-height: 78px !important;
    padding: 12px !important;
    scroll-snap-align: start;
  }

  .tasks-list-page .list-toolbar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 10px !important;
    align-items: center !important;
    margin-top: 14px !important;
  }

  .tasks-list-page .list-toolbar .view-toggle {
    display: none !important;
  }

  .tasks-list-page .task-sort-select {
    position: relative;
    display: block !important;
    min-width: 0 !important;
    color: var(--muted);
    font-size: 13px !important;
    font-weight: 800;
  }

  .tasks-list-page .task-sort-select span {
    display: block !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tasks-list-page .task-sort-select select {
    position: absolute;
    inset: -10px 0;
    width: 100%;
    opacity: 0;
  }

  .tasks-list-page .list-toolbar > label:last-child {
    display: flex !important;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    white-space: nowrap;
    font-size: 0;
  }

  .tasks-list-page .list-toolbar > label:last-child::before {
    content: "Показать";
    font-size: 12px;
    color: var(--muted);
    font-weight: 800;
  }

  .tasks-list-page .list-toolbar > label:last-child select {
    width: 64px !important;
    min-width: 64px !important;
    height: 38px !important;
    border-radius: 12px !important;
  }

  .tasks-list-page .list-table-card {
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
  }

  .tasks-list-page .task-list-row {
    width: 100% !important;
    max-width: 100% !important;
    display: grid !important;
    grid-template-columns: 14px minmax(0, 1fr) 36px !important;
    gap: 10px !important;
    align-items: start !important;
    min-height: 0 !important;
    padding: 16px !important;
    margin: 0 0 12px !important;
    border-radius: 18px !important;
    overflow: hidden !important;
  }

  .tasks-list-page .task-list-row .row-check {
    display: none !important;
  }

  .tasks-list-page .task-list-row .priority-dot {
    grid-column: 1 !important;
    grid-row: 1 !important;
    margin-top: 7px !important;
  }

  .tasks-list-page .task-list-row .row-main {
    grid-column: 2 !important;
    grid-row: 1 !important;
    min-width: 0 !important;
  }

  .tasks-list-page .task-list-row .row-main b {
    display: block;
    font-size: 15px !important;
    line-height: 1.25 !important;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .tasks-list-page .task-list-row .row-main p {
    margin-top: 7px !important;
    font-size: 12px !important;
    line-height: 1.35 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .tasks-list-page .task-list-row .row-main small {
    display: block !important;
    margin-top: 8px !important;
    font-size: 12px !important;
  }

  .tasks-list-page .task-list-row .row-menu {
    grid-column: 3 !important;
    grid-row: 1 !important;
    width: 34px !important;
    height: 34px !important;
    justify-self: end !important;
    border-radius: 12px !important;
  }

  .tasks-list-page .task-list-row .row-person,
  .tasks-list-page .task-list-row .row-center,
  .tasks-list-page .task-list-row .row-date,
  .tasks-list-page .task-list-row .status-badge {
    grid-column: 2 / 4 !important;
    min-width: 0 !important;
    justify-self: start !important;
  }

  .tasks-list-page .task-list-row .row-person {
    grid-row: 2 !important;
    display: flex !important;
    gap: 6px;
    align-items: baseline;
    margin-top: 4px !important;
  }

  .tasks-list-page .task-list-row .row-person span {
    display: none !important;
  }

  .tasks-list-page .task-list-row .row-person::before {
    content: "👤";
    font-size: 13px;
  }

  .tasks-list-page .task-list-row .row-person b {
    font-size: 13px !important;
    white-space: nowrap;
  }

  .tasks-list-page .task-list-row .row-person small {
    display: block !important;
    min-width: 0;
    font-size: 11px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tasks-list-page .task-list-row .row-center {
    grid-row: 3 !important;
    margin-top: 4px !important;
  }

  .tasks-list-page .task-list-row .row-date {
    grid-row: 4 !important;
    margin-top: 4px !important;
    font-size: 12px !important;
  }

  .tasks-list-page .task-list-row .status-badge {
    grid-row: 5 !important;
    margin-top: 6px !important;
    font-size: 12px !important;
    padding: 7px 10px !important;
  }

  .tasks-list-page .list-pagination {
    display: grid !important;
    gap: 10px !important;
    padding: 8px 4px 0 !important;
    text-align: center;
  }

  .tasks-list-page .list-pagination div {
    justify-content: center;
  }
}

.mobile-task-filter-row,
.mobile-filter-backdrop,
.mobile-filter-sheet {
  display: none;
}

@media (max-width: 768px) {
  html,
  body,
  .shell,
  .content,
  .tasks-list-page,
  .list-filter-panel,
  .list-table-card {
    max-width: 100%;
  }

  body {
    overflow-x: hidden;
  }

  .tasks-list-page {
    width: 100%;
    padding: 14px 12px 88px !important;
    gap: 12px;
    overflow-x: clip;
  }

  .tasks-list-page .list-filter-panel {
    padding: 14px;
    border-radius: 18px;
    overflow: hidden;
  }

  .tasks-list-page .list-filter-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
  }

  .tasks-list-page .list-filter-grid > label:not(.task-search-field),
  .tasks-list-page .list-filter-grid > .reset-filters {
    display: none;
  }

  .tasks-list-page .task-search-field {
    grid-column: 1;
    width: 100%;
  }

  .tasks-list-page .task-search-field span {
    font-size: 13px;
    margin-bottom: 8px;
  }

  .tasks-list-page .task-search-field input {
    height: 50px;
    border-radius: 14px;
    font-size: 14px;
  }

  .mobile-task-filter-row {
    display: flex;
    margin-top: 12px;
  }

  .mobile-filter-trigger {
    width: 100%;
    height: 46px;
    border-radius: 14px;
    font-size: 14px;
  }

  .tasks-list-page .summary-strip {
    display: flex;
    grid-template-columns: none;
    gap: 10px;
    margin: 14px -14px 0;
    padding: 14px 14px 2px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    border-top: 1px solid var(--line);
    -webkit-overflow-scrolling: touch;
  }

  .tasks-list-page .summary-strip::-webkit-scrollbar {
    display: none;
  }

  .tasks-list-page .summary-card {
    flex: 0 0 128px;
    width: 128px;
    min-width: 128px;
    min-height: 78px;
    padding: 12px;
    scroll-snap-align: start;
  }

  .tasks-list-page .summary-card b {
    font-size: 12px;
  }

  .tasks-list-page .summary-card strong {
    font-size: 20px;
  }

  .tasks-list-page .list-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    margin-top: 14px;
  }

  .tasks-list-page .list-toolbar .view-toggle {
    display: none;
  }

  .tasks-list-page .task-sort-select {
    position: relative;
    display: block;
    min-width: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
  }

  .tasks-list-page .task-sort-select span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tasks-list-page .task-sort-select select {
    position: absolute;
    inset: -10px 0 -10px 0;
    width: 100%;
    opacity: 0;
  }

  .tasks-list-page .list-toolbar > label:last-child {
    display: flex;
    gap: 8px;
    align-items: center;
    white-space: nowrap;
    font-size: 0;
  }

  .tasks-list-page .list-toolbar > label:last-child::before {
    content: "Показать";
    font-size: 12px;
    color: var(--muted);
    font-weight: 800;
  }

  .tasks-list-page .list-toolbar > label:last-child select {
    width: 64px;
    min-width: 64px;
    height: 38px;
    border-radius: 12px;
  }

  .tasks-list-page .list-table-card {
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    overflow: visible;
  }

  .tasks-list-page .task-list-row {
    width: 100%;
    max-width: 100%;
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr) 36px;
    gap: 10px;
    align-items: start;
    min-height: 0;
    padding: 16px;
    margin: 0 0 12px;
    border-radius: 18px;
    overflow: hidden;
  }

  .tasks-list-page .task-list-row .row-check {
    display: none;
  }

  .tasks-list-page .task-list-row .priority-dot {
    grid-column: 1;
    grid-row: 1;
    margin-top: 7px;
  }

  .tasks-list-page .task-list-row .row-main {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }

  .tasks-list-page .task-list-row .row-main b {
    font-size: 15px;
    line-height: 1.25;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .tasks-list-page .task-list-row .row-main p {
    margin-top: 7px;
    font-size: 12px;
    line-height: 1.35;
    -webkit-line-clamp: 2;
  }

  .tasks-list-page .task-list-row .row-main small {
    display: block;
    margin-top: 8px;
    font-size: 12px;
  }

  .tasks-list-page .task-list-row .row-menu {
    grid-column: 3;
    grid-row: 1;
    width: 34px;
    height: 34px;
    justify-self: end;
    border-radius: 12px;
  }

  .tasks-list-page .task-list-row .row-person,
  .tasks-list-page .task-list-row .row-center,
  .tasks-list-page .task-list-row .row-date,
  .tasks-list-page .task-list-row .status-badge {
    grid-column: 2 / 4;
    min-width: 0;
    justify-self: start;
  }

  .tasks-list-page .task-list-row .row-person {
    grid-row: 2;
    display: flex;
    gap: 6px;
    align-items: baseline;
    margin-top: 4px;
  }

  .tasks-list-page .task-list-row .row-person span {
    display: none;
  }

  .tasks-list-page .task-list-row .row-person::before {
    content: "👤";
    font-size: 13px;
  }

  .tasks-list-page .task-list-row .row-person b {
    font-size: 13px;
    white-space: nowrap;
  }

  .tasks-list-page .task-list-row .row-person small {
    display: block;
    min-width: 0;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tasks-list-page .task-list-row .row-center {
    grid-row: 3;
    margin-top: 4px;
  }

  .tasks-list-page .task-list-row .row-date {
    grid-row: 4;
    margin-top: 4px;
    font-size: 12px;
  }

  .tasks-list-page .task-list-row .status-badge {
    grid-row: 5;
    margin-top: 6px;
    font-size: 12px;
    padding: 7px 10px;
  }

  .tasks-list-page .list-pagination {
    display: grid;
    gap: 10px;
    padding: 8px 4px 0;
    text-align: center;
  }

  .tasks-list-page .list-pagination div {
    justify-content: center;
  }

  .mobile-filter-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(6, 12, 22, .48);
    backdrop-filter: blur(4px);
  }

  .mobile-filter-sheet {
    display: grid;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 41;
    gap: 14px;
    max-height: min(82dvh, 620px);
    padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
    border-radius: 24px 24px 0 0;
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: 0 -24px 60px rgba(0, 0, 0, .24);
    animation: mobileSheetIn .18s ease both;
  }

  .mobile-filter-sheet__handle {
    width: 46px;
    height: 5px;
    border-radius: 999px;
    background: var(--line);
    justify-self: center;
  }

  .mobile-filter-sheet__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .mobile-filter-sheet__head h2 {
    margin: 0;
    font-size: 20px;
  }

  .mobile-filter-sheet__head button {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--surface-card-2);
    color: var(--muted);
    font-size: 24px;
  }

  .mobile-filter-sheet label {
    display: grid;
    gap: 7px;
    font-size: 12px;
    color: var(--muted);
  }

  .mobile-filter-sheet select {
    width: 100%;
    height: 48px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    padding: 0 12px;
  }

  .mobile-filter-sheet__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 4px;
  }
}

@keyframes mobileSheetIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.documents-page {
  max-width: 1600px;
}

.documents-tabs {
  display: flex;
  gap: 22px;
  border-bottom: 1px solid var(--line);
  margin: -4px 0 22px;
}

.documents-tabs button {
  padding: 14px 4px;
  color: var(--muted);
  font-weight: 800;
  border-bottom: 3px solid transparent;
}

.documents-tabs button.selected {
  color: var(--brand-dark);
  border-bottom-color: var(--brand);
}

.documents-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
  align-items: start;
}

.documents-main,
.documents-side {
  display: grid;
  gap: 16px;
}

.document-upload-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 22px;
  align-items: center;
}

.document-upload-card.drag-over {
  border-color: rgba(20, 184, 174, .55);
  box-shadow: 0 0 0 4px rgba(20, 184, 174, .12), var(--shadow);
}

.document-drop-zone {
  min-height: 220px;
  border: 2px dashed rgba(113, 128, 154, .32);
  border-radius: 18px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 26px;
  background: rgba(255,255,255,.34);
}

.document-drop-zone i {
  font-style: normal;
  font-size: 46px;
  color: var(--muted);
}

.document-drop-zone h3 {
  font-size: 16px;
  margin: 8px 0 4px;
}

.document-drop-zone p,
.document-drop-zone small {
  color: var(--muted);
  margin: 0;
}

.document-drop-zone .primary {
  margin-top: 16px;
}

.document-rules {
  display: grid;
  gap: 12px;
}

.document-rules p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.document-filter-panel {
  display: grid;
  grid-template-columns: 1.25fr repeat(3, minmax(150px, .75fr)) auto;
  gap: 12px;
  align-items: end;
}

.document-filter-panel label {
  min-width: 0;
}

.document-table {
  display: grid;
  gap: 0;
}

.document-table-head,
.document-row {
  display: grid;
  grid-template-columns: minmax(280px, 1.5fr) 140px 120px 140px 120px 90px 100px 110px;
  align-items: center;
  gap: 12px;
}

.document-table-head {
  padding: 12px 4px;
  color: var(--muted);
  font-size: 11px;
  border-bottom: 1px solid var(--line);
}

.document-row {
  padding: 16px 4px;
  border-bottom: 1px solid var(--line);
  color: var(--text-soft);
  cursor: pointer;
  transition: .2s ease;
}

.document-row:hover {
  background: var(--surface-hover);
  border-radius: 12px;
  padding-left: 12px;
  padding-right: 12px;
}

.document-name-cell {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.document-name-cell i,
.document-mobile-card > i,
.document-upload-file i {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #fff0f0;
  color: #ef4d4d;
  font-style: normal;
  font-weight: 900;
  font-size: 11px;
}

.document-name-cell b,
.document-mobile-card b {
  color: var(--text);
  font-size: 13px;
}

.document-name-cell small,
.document-mobile-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.document-row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.document-row-actions button,
.document-mobile-card button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--panel);
}

.status-pill.ok {
  background: rgba(20, 184, 174, .14);
  color: var(--brand-dark);
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 10px;
}

.document-mobile-list {
  display: none;
}

.document-mobile-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto 36px;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.document-mobile-card p {
  margin: 3px 0;
}

.document-side-card {
  display: grid;
  gap: 12px;
}

.document-side-card div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-soft);
}

.document-side-card button,
.text-link {
  text-align: left;
  color: var(--brand-dark);
  font-weight: 800;
}

.storage-bar {
  height: 8px;
  background: var(--line-soft);
  border-radius: 999px;
  overflow: hidden;
}

.storage-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-dark));
  border-radius: inherit;
}

.document-upload-form {
  width: min(900px, calc(100vw - 48px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);
  border-radius: 18px;
  box-sizing: border-box;
}

dialog.document-upload-dialog {
  width: min(900px, calc(100vw - 48px));
  max-width: calc(100vw - 48px);
  max-height: calc(100dvh - 48px);
  overflow: hidden;
  background: var(--panel);
  border-radius: 18px;
}

dialog.document-upload-dialog::backdrop {
  background: rgba(15, 27, 43, .46);
}

.document-upload-modal-head,
.document-upload-modal-footer {
  flex: 0 0 auto;
  padding: 22px 28px;
  background: var(--panel);
  z-index: 1;
}

.document-upload-modal-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.document-upload-modal-head h2 {
  margin: 0 0 6px;
}

.document-modal-close {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-card-2);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.document-upload-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px 28px;
  display: grid;
  gap: 16px;
}

.document-upload-modal-body > *,
.document-upload-modal-body label,
.document-upload-modal-body input,
.document-upload-modal-body select,
.document-upload-modal-body textarea,
.document-upload-queue,
.document-upload-file {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.document-upload-modal-footer {
  position: sticky;
  bottom: 0;
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 24px rgba(15, 27, 43, .06);
}

.document-dialog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.document-field-wide {
  width: 100%;
}

.document-upload-queue {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--surface-card-2);
}

.document-queue-head,
.document-upload-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.document-upload-file {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: var(--panel);
}

.document-upload-file div {
  flex: 1;
  min-width: 0;
}

.document-upload-file small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.document-upload-file b,
.document-upload-file small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-preview-dialog {
  width: min(980px, calc(100vw - 26px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  display: grid;
  gap: 14px;
}

.document-preview-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.document-preview-body {
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-card-2);
  display: grid;
  place-items: center;
}

.document-preview-body iframe,
.document-preview-body img {
  width: 100%;
  height: 70vh;
  border: 0;
  object-fit: contain;
}

.document-preview-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
}

.document-preview-meta p {
  margin: 0;
  color: var(--text-soft);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
}

[data-theme="dark"] .document-drop-zone,
[data-theme="dark"] .document-upload-file,
[data-theme="dark"] .document-preview-dialog {
  background: var(--surface-card-2);
  border-color: var(--line);
}

[data-theme="dark"] .document-row:hover,
[data-theme="dark"] .document-row-actions button,
[data-theme="dark"] .document-mobile-card button {
  background: var(--surface-hover);
}

[data-theme="dark"] .document-name-cell i,
[data-theme="dark"] .document-mobile-card > i,
[data-theme="dark"] .document-upload-file i {
  background: rgba(239, 77, 77, .15);
  color: #ff9b9b;
}

@media (max-width: 980px) {
  .documents-layout,
  .document-upload-card {
    grid-template-columns: 1fr;
  }

  .documents-side {
    display: none;
  }

  .document-filter-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
  }

  .document-filter-panel label:first-child,
  .document-filter-panel button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .documents-page {
    padding-bottom: 90px;
  }

  .documents-tabs {
    margin-top: -10px;
    justify-content: space-around;
  }

  .document-top-upload {
    display: inline-flex !important;
    padding: 8px 10px;
    font-size: 0;
  }

  .document-top-upload::after {
    content: '+';
    font-size: 18px;
  }

  .document-drop-zone {
    min-height: 210px;
    padding: 18px;
  }

  .document-drop-zone h3 {
    font-size: 14px;
  }

  .document-rules,
  .document-table {
    display: none;
  }

  .document-mobile-list {
    display: grid;
  }

  .document-filter-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .document-filter-panel label {
    font-size: 0;
  }

  .document-filter-panel input,
  .document-filter-panel select {
    font-size: 12px;
    min-width: 0;
    width: 100%;
  }

  .document-filter-panel label:first-child,
  .document-filter-panel button {
    grid-column: 1 / -1;
    font-size: 12px;
  }

  .document-preview-body {
    min-height: 240px;
  }

  .document-preview-body iframe,
  .document-preview-body img {
    height: 52vh;
  }

  .document-preview-meta {
    grid-template-columns: 1fr;
  }
}

.list-filter-panel {
  padding: 18px 20px;
}

.list-filter-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) repeat(4, minmax(150px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.list-filter-grid label {
  min-width: 0;
}

.list-filter-grid label span,
.list-toolbar label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.list-filter-grid input,
.list-filter-grid select,
.list-toolbar select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  color: var(--text);
  padding: 0 12px;
}

.search-field {
  position: relative;
}

.search-field i {
  position: absolute;
  right: 14px;
  bottom: 11px;
  color: var(--muted);
  font-style: normal;
}

.search-field input {
  padding-right: 38px;
}

.reset-filters {
  height: 42px;
  white-space: nowrap;
  padding: 0 14px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.summary-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  text-align: left;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.52);
  padding: 13px 14px;
  color: var(--text);
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.summary-card:hover {
  transform: translateY(-1px);
  border-color: rgba(20, 184, 174, 0.26);
  box-shadow: 0 12px 28px rgba(37, 67, 102, 0.08);
}

.summary-card.active {
  background: rgba(20, 184, 174, 0.08);
  border-color: rgba(20, 184, 174, 0.34);
  box-shadow: 0 14px 32px rgba(20, 184, 174, 0.1);
}

.summary-card b {
  font-size: 12px;
}

.summary-card strong {
  grid-column: 2;
  font-size: 18px;
}

.status-dot,
.priority-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #7a8aa2;
}

.status-dot.info,
.priority-dot.info {
  background: #2f86ff;
}

.status-dot.work,
.priority-dot.work {
  background: #14b8ae;
}

.status-dot.review,
.priority-dot.review {
  background: #a044e8;
}

.status-dot.done,
.priority-dot.done {
  background: #18b96f;
}

.status-dot.danger,
.priority-dot.danger,
.priority-dot.high {
  background: #f04444;
}

.priority-dot.medium {
  background: #f5a400;
}

.priority-dot.muted {
  background: #94a3b8;
}

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.list-toolbar label {
  display: flex;
  align-items: center;
  gap: 9px;
}

.list-toolbar select {
  height: 36px;
  min-width: 112px;
}

.view-toggle {
  display: flex;
  gap: 6px;
}

.view-toggle button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 900;
}

.view-toggle button.active {
  background: linear-gradient(135deg, #14b8ae, #0e9b96);
  border-color: transparent;
  color: #fff;
}

.list-table-card {
  padding: 14px;
}

.list-row-card {
  display: grid;
  grid-template-columns: 34px 14px minmax(250px, 1.5fr) minmax(180px, 0.85fr) minmax(105px, 0.55fr) minmax(140px, 0.7fr) 112px 42px;
  gap: 14px;
  align-items: center;
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.54);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.list-row-card:last-child {
  margin-bottom: 0;
}

.list-row-card:hover {
  transform: translateY(-1px);
  border-color: rgba(20, 184, 174, 0.24);
  box-shadow: 0 14px 30px rgba(37, 67, 102, 0.08);
}

.list-row-card:focus-visible {
  outline: 2px solid rgba(20, 184, 174, 0.55);
  outline-offset: 2px;
}

.row-check input {
  width: 20px;
  height: 20px;
  accent-color: #14b8ae;
}

.row-main {
  min-width: 0;
}

.row-main b {
  display: block;
  color: var(--text);
  font-size: 13px;
  line-height: 1.28;
}

.row-main p {
  margin: 5px 0 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.row-main small {
  color: var(--muted);
  font-size: 11px;
}

.row-person {
  display: grid;
  grid-template-columns: 38px 1fr;
  column-gap: 9px;
  align-items: center;
  min-width: 0;
}

.row-person span {
  grid-row: 1 / 3;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #dbf7f3;
  color: #078e86;
  font-weight: 900;
}

.row-person b {
  font-size: 12px;
  line-height: 1.25;
}

.row-person small {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.3;
}

.row-center {
  justify-self: start;
  background: #f1f7ff;
  color: #577095;
  border-radius: 9px;
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 800;
}

.row-date {
  display: grid;
  gap: 2px;
  font-size: 11px;
  color: var(--text);
  font-weight: 900;
}

.row-date em {
  font-style: normal;
  color: #f04444;
  font-size: 10px;
}

.row-date.danger {
  color: #d72f3f;
}

.status-badge {
  justify-self: start;
  border-radius: 9px;
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 900;
  background: #eef3f8;
  color: #60718a;
}

.status-badge.work {
  background: #dcf8ef;
  color: #078e86;
}

.status-badge.done {
  background: #dcf8ef;
  color: #12965b;
}

.status-badge.info {
  background: #e4f0ff;
  color: #287ee7;
}

.status-badge.review {
  background: #f1e4ff;
  color: #8a3ed8;
}

.status-badge.danger {
  background: #ffe8ea;
  color: #e23545;
}

.status-badge.muted {
  background: #eef1f5;
  color: #74829a;
}

.row-menu {
  width: 38px;
  height: 38px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: var(--muted);
  font-size: 20px;
  font-weight: 900;
}

.row-menu:hover {
  background: rgba(20, 184, 174, 0.09);
  border-color: rgba(20, 184, 174, 0.18);
  color: var(--brand);
}

.list-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
}

.list-pagination div {
  display: flex;
  gap: 7px;
}

.list-pagination button {
  min-width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 900;
}

.list-pagination button.active {
  background: linear-gradient(135deg, #14b8ae, #0e9b96);
  color: #fff;
  border-color: transparent;
}

.list-pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.action-menu-dialog {
  padding: 18px;
  display: grid;
  gap: 8px;
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid var(--line);
}

.action-menu-dialog h2 {
  font-size: 16px;
  margin: 0 0 4px;
}

.action-menu-dialog button {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.5);
  font-weight: 800;
}

.action-menu-dialog button:hover {
  border-color: rgba(20, 184, 174, 0.28);
  background: rgba(20, 184, 174, 0.08);
}

.announcement-list-row {
  grid-template-columns: 34px 14px minmax(260px, 1.6fr) minmax(180px, 0.85fr) minmax(115px, 0.58fr) minmax(142px, 0.72fr) 118px 42px;
}

.list-row-card.is-muted {
  opacity: 0.72;
}

.list-row-card.is-overdue {
  border-color: rgba(240, 68, 68, 0.18);
}

.top-new-button {
  white-space: nowrap;
}

[data-theme="dark"] .list-filter-panel,
[data-theme="dark"] .list-table-card {
  background: linear-gradient(180deg, rgba(23, 36, 53, 0.96), rgba(18, 30, 45, 0.94));
  border-color: var(--line);
}

[data-theme="dark"] .list-filter-grid input,
[data-theme="dark"] .list-filter-grid select,
[data-theme="dark"] .list-toolbar select,
[data-theme="dark"] .view-toggle button,
[data-theme="dark"] .list-pagination button {
  background: #101c2c;
  border-color: var(--line);
  color: var(--text);
}

[data-theme="dark"] .summary-card,
[data-theme="dark"] .list-row-card {
  background: rgba(28, 42, 60, 0.52);
  border-color: var(--line);
  box-shadow: none;
}

[data-theme="dark"] .summary-card:hover,
[data-theme="dark"] .list-row-card:hover {
  background: rgba(34, 50, 71, 0.58);
  border-color: rgba(173, 195, 222, 0.22);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.18);
}

[data-theme="dark"] .summary-card.active {
  background: rgba(24, 196, 181, 0.14);
  border-color: rgba(24, 196, 181, 0.34);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
}

[data-theme="dark"] .row-person span {
  background: rgba(24, 196, 181, 0.14);
  color: #5ee4d6;
}

[data-theme="dark"] .row-center {
  background: #20324a;
  color: #aebbd0;
}

[data-theme="dark"] .row-date {
  color: var(--text);
}

[data-theme="dark"] .status-badge {
  background: #20324a;
  color: #aebbd0;
}

[data-theme="dark"] .status-badge.work,
[data-theme="dark"] .status-badge.done {
  background: rgba(24, 196, 181, 0.14);
  color: #5ee4d6;
}

[data-theme="dark"] .status-badge.info {
  background: rgba(80, 150, 255, 0.14);
  color: #8dbbff;
}

[data-theme="dark"] .status-badge.review {
  background: rgba(160, 68, 232, 0.15);
  color: #d2a5ff;
}

[data-theme="dark"] .status-badge.danger {
  background: rgba(240, 68, 68, 0.14);
  color: #ff9ba5;
}

[data-theme="dark"] .action-menu-dialog {
  background: linear-gradient(180deg, #172435, #121e2d);
  border-color: var(--line);
}

[data-theme="dark"] .action-menu-dialog button {
  background: rgba(28, 42, 60, 0.58);
  border-color: var(--line);
  color: var(--text);
}

[data-theme="dark"] .action-menu-dialog button:hover {
  background: var(--surface-hover);
  border-color: rgba(24, 196, 181, 0.28);
}

@media (max-width: 1180px) {
  .list-filter-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .reset-filters {
    width: 100%;
  }

  .summary-strip {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .list-row-card {
    grid-template-columns: 28px 12px minmax(220px, 1fr) minmax(150px, 0.8fr) 96px 118px 106px 38px;
    gap: 10px;
  }

  .row-center,
  .row-date {
    font-size: 10px;
  }
}

@media (max-width: 760px) {
  .advanced-list-page {
    padding-left: 14px !important;
    padding-right: 14px !important;
    gap: 12px;
  }

  .top-new-button {
    padding: 9px 11px;
    font-size: 0;
  }

  .top-new-button::after {
    content: "+";
    font-size: 18px;
  }

  .list-filter-panel {
    padding: 14px;
    border-radius: 16px;
  }

  .list-filter-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .list-filter-grid .search-field {
    grid-column: 1 / -1;
  }

  .list-filter-grid label span {
    font-size: 10px;
  }

  .list-filter-grid input,
  .list-filter-grid select {
    height: 40px;
  }

  .summary-strip {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    margin-left: -14px;
    margin-right: -14px;
    padding-left: 14px;
    padding-right: 14px;
    scroll-snap-type: x mandatory;
  }

  .summary-card {
    min-width: 142px;
    scroll-snap-align: start;
    min-height: 66px;
  }

  .list-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .list-toolbar label {
    justify-content: space-between;
  }

  .view-toggle {
    display: none;
  }

  .list-table-card {
    padding: 10px;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .list-row-card,
  .announcement-list-row {
    display: grid;
    grid-template-columns: 14px 1fr 38px;
    gap: 8px;
    align-items: start;
    min-height: 0;
    padding: 14px;
    margin-bottom: 10px;
    background: var(--panel);
    border-radius: 16px;
  }

  .row-check {
    display: none;
  }

  .priority-dot {
    margin-top: 6px;
  }

  .row-main {
    grid-column: 2;
    grid-row: 1;
  }

  .row-main b {
    font-size: 14px;
  }

  .row-main p {
    font-size: 12px;
  }

  .row-person {
    grid-column: 2;
    grid-row: 2;
    display: block;
  }

  .row-person span {
    display: none;
  }

  .row-person b {
    font-size: 12px;
  }

  .row-center {
    grid-column: 2;
    grid-row: 3;
    justify-self: start;
  }

  .row-date {
    grid-column: 2;
    grid-row: 4;
  }

  .status-badge {
    grid-column: 2;
    grid-row: 5;
    justify-self: start;
  }

  .row-menu {
    grid-column: 3;
    grid-row: 1;
    width: 34px;
    height: 34px;
  }

  .list-pagination {
    display: grid;
    gap: 10px;
    text-align: center;
  }

  .list-pagination div {
    justify-content: center;
  }

  .list-pagination span {
    font-size: 11px;
  }

  .reset-filters {
    grid-column: 1 / -1;
  }

  .action-menu-dialog {
    width: 100%;
  }
}

@media (max-width: 720px) {
  dialog.document-upload-dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
  }

  .document-upload-form {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .document-upload-modal-head {
    padding: calc(16px + env(safe-area-inset-top)) 16px 14px;
  }

  .document-upload-modal-body {
    padding: 16px;
    gap: 14px;
  }

  .document-upload-modal-footer {
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  }

  .document-dialog-grid {
    grid-template-columns: 1fr;
  }

  .document-upload-file {
    grid-template-columns: 38px minmax(0, 1fr) 32px;
    display: grid;
  }

  .document-upload-file button {
    width: 32px;
    height: 32px;
  }
}
/* Mobile Tasks override must be last: it prevents the shared desktop list
   rules from squeezing the Tasks page into a mini desktop table on phones. */
@media (max-width: 768px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .content.tasks-list-page {
    width: 100%;
    min-width: 0 !important;
    max-width: 100% !important;
    padding: 14px 12px 88px !important;
    gap: 12px !important;
    overflow-x: clip;
  }

  .tasks-list-page .list-filter-panel,
  .tasks-list-page .list-table-card,
  .tasks-list-page .list-row-card {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  .tasks-list-page .list-filter-panel {
    padding: 14px !important;
    border-radius: 18px !important;
    overflow: hidden;
  }

  .tasks-list-page .list-filter-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 0 !important;
  }

  .tasks-list-page .list-filter-grid > label:not(.task-search-field),
  .tasks-list-page .list-filter-grid > .reset-filters {
    display: none !important;
  }

  .tasks-list-page .task-search-field {
    display: grid !important;
    grid-column: 1 !important;
    width: 100%;
    gap: 8px;
  }

  .tasks-list-page .task-search-field input {
    height: 50px !important;
    border-radius: 14px !important;
    font-size: 14px !important;
  }

  .tasks-list-page .mobile-task-filter-row {
    display: flex !important;
    margin-top: 12px;
  }

  .tasks-list-page .mobile-filter-trigger {
    width: 100%;
    height: 46px;
    border-radius: 14px;
    justify-content: center;
  }

  .tasks-list-page .summary-strip {
    display: flex !important;
    grid-template-columns: none !important;
    gap: 10px !important;
    margin: 14px -14px 0 !important;
    padding: 14px 14px 2px !important;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    border-top: 1px solid var(--line);
    -webkit-overflow-scrolling: touch;
  }

  .tasks-list-page .summary-strip::-webkit-scrollbar {
    display: none;
  }

  .tasks-list-page .summary-card {
    flex: 0 0 128px !important;
    width: 128px !important;
    min-width: 128px !important;
    min-height: 78px !important;
    padding: 12px !important;
    scroll-snap-align: start;
  }

  .tasks-list-page .list-toolbar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 10px !important;
    align-items: center !important;
    margin-top: 14px !important;
  }

  .tasks-list-page .list-toolbar .view-toggle {
    display: none !important;
  }

  .tasks-list-page .task-sort-select {
    position: relative;
    display: block !important;
    min-width: 0 !important;
    color: var(--muted);
    font-size: 13px !important;
    font-weight: 800;
  }

  .tasks-list-page .task-sort-select span {
    display: block !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tasks-list-page .task-sort-select select {
    position: absolute;
    inset: -10px 0;
    width: 100%;
    opacity: 0;
  }

  .tasks-list-page .list-toolbar > label:last-child {
    display: flex !important;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    white-space: nowrap;
    font-size: 0;
  }

  .tasks-list-page .list-toolbar > label:last-child::before {
    content: "Показать";
    font-size: 12px;
    color: var(--muted);
    font-weight: 800;
  }

  .tasks-list-page .list-toolbar > label:last-child select {
    width: 64px !important;
    min-width: 64px !important;
    height: 38px !important;
    border-radius: 12px !important;
  }

  .tasks-list-page .list-table-card {
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
  }

  .tasks-list-page .task-list-row {
    width: 100% !important;
    max-width: 100% !important;
    display: grid !important;
    grid-template-columns: 14px minmax(0, 1fr) 36px !important;
    gap: 10px !important;
    align-items: start !important;
    min-height: 0 !important;
    padding: 16px !important;
    margin: 0 0 12px !important;
    border-radius: 18px !important;
    overflow: hidden !important;
  }

  .tasks-list-page .task-list-row .row-check {
    display: none !important;
  }

  .tasks-list-page .task-list-row .priority-dot {
    grid-column: 1 !important;
    grid-row: 1 !important;
    margin-top: 7px !important;
  }

  .tasks-list-page .task-list-row .row-main {
    grid-column: 2 !important;
    grid-row: 1 !important;
    min-width: 0 !important;
  }

  .tasks-list-page .task-list-row .row-main b {
    display: block;
    font-size: 15px !important;
    line-height: 1.25 !important;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .tasks-list-page .task-list-row .row-main p {
    margin-top: 7px !important;
    font-size: 12px !important;
    line-height: 1.35 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .tasks-list-page .task-list-row .row-main small {
    display: block !important;
    margin-top: 8px !important;
    font-size: 12px !important;
  }

  .tasks-list-page .task-list-row .row-menu {
    grid-column: 3 !important;
    grid-row: 1 !important;
    width: 34px !important;
    height: 34px !important;
    justify-self: end !important;
    border-radius: 12px !important;
  }

  .tasks-list-page .task-list-row .row-person,
  .tasks-list-page .task-list-row .row-center,
  .tasks-list-page .task-list-row .row-date,
  .tasks-list-page .task-list-row .status-badge {
    grid-column: 2 / 4 !important;
    min-width: 0 !important;
    justify-self: start !important;
  }

  .tasks-list-page .task-list-row .row-person {
    grid-row: 2 !important;
    display: flex !important;
    gap: 6px;
    align-items: baseline;
    margin-top: 4px !important;
  }

  .tasks-list-page .task-list-row .row-person span {
    display: none !important;
  }

  .tasks-list-page .task-list-row .row-person::before {
    content: "👤";
    font-size: 13px;
  }

  .tasks-list-page .task-list-row .row-person b {
    font-size: 13px !important;
    white-space: nowrap;
  }

  .tasks-list-page .task-list-row .row-person small {
    display: block !important;
    min-width: 0;
    font-size: 11px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tasks-list-page .task-list-row .row-center {
    grid-row: 3 !important;
    margin-top: 4px !important;
  }

  .tasks-list-page .task-list-row .row-date {
    grid-row: 4 !important;
    margin-top: 4px !important;
    font-size: 12px !important;
  }

  .tasks-list-page .task-list-row .status-badge {
    grid-row: 5 !important;
    margin-top: 6px !important;
    font-size: 12px !important;
    padding: 7px 10px !important;
  }

  .tasks-list-page .list-pagination {
    display: grid !important;
    gap: 10px !important;
    padding: 8px 4px 0 !important;
    text-align: center;
  }

  .tasks-list-page .list-pagination div {
    justify-content: center;
  }
}
