@media (max-width: 1180px) {
  .stats {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }

  .sidebar {
    width: 220px;
  }
}

@media (max-width: 820px) {
  .header {
    position: static;
    min-height: auto;
    padding: 12px 14px;
  }

  .header-info {
    width: 100%;
  }

  .header h1 {
    font-size: 15px;
  }

  .header-logo {
    width: 42px;
    height: 42px;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .layout {
    display: block;
    min-height: auto;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 110;
    width: 100%;
    height: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border-color);
  }

  .nav-section {
    display: none;
  }

  .nav-item {
    flex: 0 0 auto;
    min-height: 40px;
    margin: 0;
    padding: 8px 10px;
    font-size: 12px;
  }

  .nav-item::before {
    display: none;
  }

  .nav-item .icon {
    width: 26px;
    height: 26px;
  }

  .main {
    padding: 16px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat {
    min-height: 96px;
    padding: 14px;
  }

  .stat-icon {
    width: 40px;
    height: 40px;
  }

  .stat-val {
    font-size: 21px;
  }

  .topbar {
    align-items: stretch;
  }

  .topbar input,
  .topbar select {
    width: 100%;
    min-width: 0;
  }

  .form-grid,
  .inv-doc-parties {
    grid-template-columns: 1fr;
  }

  .modal {
    max-width: 96vw;
    padding: 17px;
  }

  .pipeline-wrap {
    grid-auto-columns: minmax(190px, 84vw);
    height: calc(100vh - 230px);
  }
}

@media (max-width: 520px) {
  body {
    font-size: 13px;
  }

  .header-info {
    align-items: flex-start;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-wrap: nowrap;
  }

  .icon-btn {
    min-width: auto;
    padding-inline: 8px;
  }

  th,
  td {
    padding: 10px;
  }

  .client-cell {
    min-width: 180px;
  }

  .modal-footer {
    justify-content: stretch;
  }

  .modal-footer .btn {
    flex: 1;
  }
}

@media (min-width: 1441px) {
  .main {
    max-width: 1840px;
    margin: 0 auto;
    padding: 32px;
  }

  .sidebar {
    width: 270px;
  }
}
